我有一个 XML 文档,它正在读取“\n”作为子节点。我正在尝试使用以下方法删除它:
XmlReaderSettings.IgnoreWhiteSpace = True
或者
XmlDocument.PreserveWhiteSpace = False
但它不工作。body 之后的子节点被读为“\n”而不是<C></C>
下面是一段代码:
Dim xrsSettings As New XmlReaderSettings()
xrsSettings.IgnoreComments = True
Dim xrReader As XmlReader = XmlReader.Create(context.Request.InputStream, xrsSettings)
Dim xdRequest As New XmlDocument()
xdRequest.Load(xrReader)
这是 XML:
<?xml version="1.0" encoding="utf-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" SOAP-ENV:mustUnderstand="1">
<wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:Username>user</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">pass</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<C xmlns="http://www.sdfsfsfs.com/3939" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" MessageContentCode="8" TimeStamp="2012-05-18T08:32:42" Version="6.000">
<A HC="ABCD">
<B CC="EUR" End="2012-06-30" IAI="false" IC="0" MC="P1" RPC="BAR" RPT="Overlay" Start="2012-05-18" YI="false">
<RS>
<R CC="EUR" ITC="DR">
<BBGAS>
<BBGA AQC="10" AAT="300" NOG="1" />
<BBGA AQC="10" AAT="300" NOG="2" />
<BBGA AQC="10" AAT="300" NOG="3" />
</BBGAS>
</R>
</RS>
<D N="Short">
<T L="DE">BAR</T>
</D>
</B>
</A>
</C>
</SOAP-ENV:Body></SOAP-ENV:Envelope>