【发布时间】:2021-06-07 20:54:13
【问题描述】:
我一直在努力尝试使用 Linq(根本不是 Linq 的任何附件,它只是我发现的示例中最常用的)解析下面的 XML Soap 响应。我已经尝试了一些已经在 StackOverflow 上发布的类似答案,但它们都没有处理 XML 结构的不同元素上的这些多个命名空间。 SOAP 响应是一团糟,我知道,但它是给定的。我唯一需要的是 itemID 字段中的值(即 MyITItemName)
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header
xmlns:ns="http://services.mycompany.biz/it/managementservice/ITSMIT/1/"
xmlns:ns1="http://schemata.mycompany.biz/it/managementservice/ITSMIT/1/"/>
<soapenv:Body
xmlns:ns="http://services.mycompany.biz/it/managementservice/ITSMIT/1/"
xmlns:ns1="http://schemata.mycompany.biz/it/managementservice/ITSMIT/1/">
<ns1:createItemResponse
xmlns:ns1="http://services.mycompany.biz/it/managementservice/ITSMIT/1/">
<ns2:id
xmlns:ns2="http://schemata.mycompany.biz/it/managementservice/ITSMIT/1/">338632
</ns2:id>
<ns2:itemID
xmlns:ns2="http://schemata.mycompany.biz/it/managementservice/ITSMIT/1/">MyITItemName
</ns2:itemID>
</ns1:createItemResponse>
</soapenv:Body>
</soapenv:Envelope>
任何人都可以对此有所了解(或一些代码:-))吗?
【问题讨论】: