有人可以以最佳方式帮助我以 xml 格式的方式向浏览器显示原始 xml 字符串吗?
我在下面创建的代码不显示任何内容并出错:
string xml = GetMessageXml(Request.QueryString["ID"].ToString());
XDocument doc;
using (StringReader s = new StringReader(xml.Substring(1)))
{
doc = XDocument.Load(s);
}
Response.ContentType = "text/xml";
doc.Save(Response.Output);
Response.Write(doc.ToString());
错误:
XML 解析错误:文档元素
'Location:H ttp: localhost/Accounts/EventLogMessageDetails.aspx?id=178'
第 83 行,第 9 列:'
这是 xml 字符串:
?<?xml version="1.0" encoding="utf-8"?>
<Order xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<OrderID>00000000-0000-0000-0000-000000000000</OrderID>
<IsOrderThrough>true</IsOrderThrough>
<VendorName>le</VendorName>
<OrderUniqueIdentifier>K03936</OrderUniqueIdentifier>
<SoldToCustomerID>A786</SoldToCustomerID>
<ShipToCustomerID>A786</ShipToCustomerID>
<OrderType>Standard</OrderType>
<CustomerPurchaseOrderNumber>PO0000336</CustomerPurchaseOrderNumber>
<ProjectName />
<EmailAddress>Nair@ecomkva.com</EmailAddress>
<DeliveryDate>2012-05-29T10:09:55.492696-05:00</DeliveryDate>
<ShipToAddress>
<AddressID>00075</AddressID>
<OrganizationName>SEBA-E</OrganizationName>
<AddressLine1>3700 STATE</AddressLine1>
<AddressLine2>Elk</AddressLine2>
<City>LA CROSSE</City>
<State>WI</State>
<ZipCode>54601</ZipCode>
<Country>US</Country>
<DaytimePhoneNumber>6782260680EXT</DaytimePhoneNumber>
</ShipToAddress>
<ShippingMethodName>FEDEX PRIORITY OVERNIGHT</ShippingMethodName>
<ShippingMethodID>F01</ShippingMethodID>
<MarketSegment>Commercial</MarketSegment>
<Comments>Elk^</Comments>
<LineItems>
<OrderLineItem>
<LineItemID>00000000-0000-0000-0000-000000000000</LineItemID>
<ProductID>Kbv</ProductID>
<Quantity>2</Quantity>
<ListPrice>10.67</ListPrice>
<PlacedPrice>3.84</PlacedPrice>
<DeliveryDate>2012-05-29T10:09:56.6957979-05:00</DeliveryDate>
<ShippingAddress>
<AddressID>Z00138075</AddressID>
<OrganizationName>moomoo</OrganizationName>
<AddressLine1>3700 STATE ROAD 16</AddressLine1>
<AddressLine2>moomoo</AddressLine2>
<City>LA CROSSE</City>
<State>WI</State>
<ZipCode>54601</ZipCode>
<Country>US</Country>
<DaytimePhoneNumber>675555550680EXT</DaytimePhoneNumber>
</ShippingAddress>
<ShippingMethodID>F01</ShippingMethodID>
<EmailAddress>IS@Cnj.com</EmailAddress>
<Comments />
<SequenceNumber>0</SequenceNumber>
</OrderLineItem>
</LineItems>
<BusinessUnit />
<FOBPoint>FB2</FOBPoint>
<Notify>TD</Notify>
<WorkOrder />
<SubmittedByUserName>TDAVIS</SubmittedByUserName>
<SpecialInstructions />
</Order>