必须在文档根元素之前定义xml加载错误DTD

时间:2018-10-31 07:32:01

标签: c# xml

我正在尝试加载xml文件,但出现以下错误。

  

DTD必须在文档根元素之前定义。

xml文件是由其他人生成的,我发现xml文件中有html元素。如何使用C#删除xml文件中的html?

已更新:

嗨,对不起,由于公司p&c,我无法显示完整的xml文件。但是下面是我提到的html部分。

<?xml version="1.0" encoding="UTF-8"?>
<loanreservation>
<loanid></loanid>
<status>WEB_REQUEST</status>
<requesterid>abc</requesterid>
<borrowerid>abc</borrowerid>
<borrowerorgid>abc</borrowerorgid>
<borrowerlocid>abcborrowerlocid>
<authcontactid></authcontactid>
<escalationcontactid></escalationcontactid>
<specialinstructions>specialinstructions>
<internalnotes></internalnotes>
<usestartdate>2018-09-03</usestartdate>
<useenddate>2018-09-17</useenddate>
<mustshipdate>2018-08-30</mustshipdate>
<mustreceivedate>2018-10-01</mustreceivedate>
<checkoutdate></checkoutdate>
<checkindate></checkindate>
<intendeduse></intendeduse>
<reason></reason>
<shiptolocid>abc</shiptolocid>
<shipaddress1></shipaddress1>
<shipaddress2></shipaddress2>
<shipaddress3></shipaddress3>
<shipaddress4></shipaddress4>
<shippostalcode></shippostalcode>
<shipcity></shipcity>
<shipstate></shipstate>
<shipprovince></shipprovince>
<shipcountry></shipcountry>
<shiptocontactid></shiptocontactid>
<shiptocontactphone></shiptocontactphone>
<shiptocontactfax></shiptocontactfax>
<shiptocontactemail></shiptocontactemail>
<returnpickuplocid></returnpickuplocid>
<returnpickupcontactid></returnpickupcontactid>
<returnpickupcontactphone></returnpickupcontactphone>
<returnpickupcontactfx></returnpickupcontactfx>
<returnpickupcontactemail></returnpickupcontactemail>
<returnpickuplocation></returnpickuplocation>
<returnpickupaddress1></returnpickupaddress1>
<returnpickupaddress2></returnpickupaddress2>
<returnpickupaddress3></returnpickupaddress3>
<returnpickupaddress4></returnpickupaddress4>
<returnpickuppostalcode></returnpickuppostalcode>
<returnpickupcity></returnpickupcity>
<returnpickupstate></returnpickupstate>
<returnpickupprovince></returnpickupprovince>
<returnpickupcountry></returnpickupcountry>
<loanorgpoolid></loanorgpoolid>
<contactloginid></contactloginid>
<lastupdate></lastupdate>
<createdate></createdate>
<approvalcontactid></approvalcontactid>
<approveddate></approveddate>
<shippingwaybill></shippingwaybill>
<shippingcarrier></shippingcarrier>
<shippingnoofboxes></shippingnoofboxes>
<shippingtotalweight></shippingtotalweight>
<returnwaybill></returnwaybill>
<returncarrier></returncarrier>
<returnnoofboxes></returnnoofboxes>
<returntotalweight></returntotalweight>
<reservationitems>
<item>
<loanid></loanid>
<equipno></equipno>
<assetno></assetno>
<manufacturer></manufacturer>
<manufmodelno></manufmodelno>
<serialno></serialno>
<options></options>
<chassisno></chassisno>
<slotno></slotno>
<configid></configid>
</item>
</reservationitems>
<accessories>
<item></item>
</accessories>
</loanreservation>

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html style="height: 100%">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <title></title>
    <link rel="stylesheet" type="text/css" href="../css/base-font.css">
    <link rel="stylesheet" type="text/css" href="../css/style.css">
    <link rel="stylesheet" type="text/css" href="../css/template.css">
    <link rel="stylesheet" type="text/css" href="../css/dashboard.css">
    <link rel="stylesheet" type="text/css" href="../css/tabs.css">
    <link rel="stylesheet" type="text/css" href="../css/webforms.css">
    <link rel="stylesheet" type="text/css" href="../css/im.css">
    <link rel="stylesheet" type="text/css" href="../css/ice_infoline.css">
    <link rel="stylesheet" type="text/css" href="../css/internal_portal.css">
    <script language="JavaScript" src="../scripts/dhtml-base.js"></script>
    <script language="JavaScript" src="../scripts/common.js"></script>
    <script language="JavaScript" src="../scripts/jquery-min.js"></script>
    <script language="JavaScript" src="../public/locale-script.aspx"></script>
    <script language="JavaScript" src="../scripts/template.js"></script>
    <script language="JavaScript" src="../scripts/dhtml-menus.js"></script>
    <script language="JavaScript" src="../scripts/report-definition.js"></script>
    <script language="JavaScript" src="../webfx/scripts/webforms-ui.js"></script>
    <script src="../webfx/scripts/webforms.js"></script>
    </head>


    <body style="height: 100%;">
    <div style="position: fixed; top: 0px; width:60px; height: 100%; background-color: #555555;"></div>
    <div style="margin-left:0px; height: 100%">
    <div style="display: table; height: 100%; width: 100%">
    <div style="display: table-row; width=100%">
    <div style="border-bottom:6px #e90029 solid; margin-bottom: 10px;  ">
    <div class="bodycontainer">
    <a style="display: inline-block;" href="http://www.keysight.com"><img src="../acom-lf/keysight-logo.png"></a>
    <span style="display: inline-block; color: #555555; font-size: 20pt; font-weight: bold; vertical-align: top; padding-top: 20px; margin-left: 30px" >Infoline</span>
    </div>  
    </div>
    </div>
    <div style="display: table-row; width=100%; height: 100%">
    <div class="bodycontainer" style=" ">
    <h1>System maintenance</h1>

    </div>
    </div>
    <div style="display: table-row; width=100%">
    <div style="color: #909090; background-color: black; padding: 8px; padding-left:50px; margin-top: 20px; font-size: 9pt;" class="bodycontainerhf"> 
    </script></strong> 
    </div>
    </div>
    </div>
    </div>
    </body>
    </html>

对于编码部分,我正在做以下事情:

xmlDoc.Load(Server.MapPath(“ ./ Request /”)+ FileUpload1.FileName); 我正在做的只是加载xml文件。

0 个答案:

没有答案