Xml结构
<soap-env:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<mm7:id xmlns:mm7="http://schemas.xmlsoap.org/soap/envelope/" mustUnderstand="1">1234</mm7:id>
</soapenv:Header>
<soap-env:Body>
<SubmitReq>
<number xmlns="">5674</number>
</SubmitReq>
</soap-env:Body>
</soapenv:Envelope>编码
Dim bodychild As XmlElement = _xmlRequest.CreateElement("SubmitReq", "http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-2")
soapBody.AppendChild(bodychild)
Dim numberAs XmlElement = _xmlRequest.CreateElement("number")
number.InnerText = "5674"
bodychild.AppendChild(number)如何删除xmlns="“,我尝试使用RemoveAttribute和RemoveAttributeAt方法,但没有删除任何内容。是不是可以去掉它?
发布于 2014-01-23 18:21:59
我相信This question有一个答案--因为您添加的number没有命名空间,所以假设您不希望它位于其父对象的命名空间中。因为您没有指定名称空间,所以XML的规则规定它必须在文档为您指定的空名称空间中。
您应该能够通过在创建它时显式地指定与SubmitReq相同的名称空间来修复它。
发布于 2014-01-22 19:08:06
要删除属性,可以使用node.Attributes.RemoveNamedItem并将要删除的属性的名称作为参数传递,该属性将被删除。
https://stackoverflow.com/questions/21279060
复制相似问题