我有以下 xdocument ,我正在尝试使用以下代码在 items 元素中附加 item 元素:
xdocument.Root.Element("items").add(item)
这不起作用,因为找不到 items 元素。我认为这是命名空间的问题,但我似乎无法让它工作。任何帮助都感激不尽。
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://mynamespace.com" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1:getUpload>
<itemObj>
<items SOAP-ENC:arrayType="ns1:item[2]" xsi:type="ns1:ArrayOfItem">
<!--Item elements to go here-->
</items>
</itemObj>
</ns1:getUpload>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>