如何在soap消息中提取特定的xml标记值? [英] how to extract specific xml tag value in soap message?

查看:89
本文介绍了如何在soap消息中提取特定的xml标记值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的肥皂消息..我需要如何在c#中使用xdocument检索

Quote:

AttributeAssignment

值作为数组br />


Quote:

 <   SOAP-ENV:Envelope     xmlns:SOAP-ENV   =  http://schemas.xmlsoap.org/soap / envelope >  
- < SOAP-ENV:标题 >
- < 投放 >
< Src > / AA / BB / CC < / Src >
< Dest > / AA / BB / CC / DD < / Dest >
< 回复 / >
< / Delivery >
< MTXMLMsg MsgType = REPLY / >
< / SOAP-ENV:标题 >
- < SOAP-ENV:正文 >
- < 响应 >
- < 结果 xmlns = http://xacml.aa。 web.com >
- < 结果 >
< 决定 > 允许< /决定 >
- < 状态 >
< StatusCode = urn:oasis:names:tc:xacml:1.0:status:ok < span class =code-keyword> / >
< /状态 >
- < 义务 >
- < 义务 FulfillOn = 拒绝 ObligationId = PutInCache >
< AttributeAssignment < span class =code-attribute> AttributeId = resource DataType = http://www.w3.org/2001/XMLSchema#string > Appgrp:App:grp2 < / AttributeAssignment >
< /义务 >
- < 义务 FulfillOn = 拒绝 ObligationId = PutInCache >
< AttributeAssignment AttributeId = 资源 < span class =code-attribute> DataType = http://www.w3.org/2001/XMLSchema#string > Appgrp:App:grp1 < / AttributeAssignment >
< / Obligation >
- < 义务 FulfillOn = 拒绝 ObligationId = PutInCache >
< Attri buteAssignment AttributeId = 资源 DataType = http://www.w3.org/2001/XMLSchema#string > Appgrp:App:grp1:subgrp1 < / AttributeAssignment > < pre > < pre lang = text > < pre lang = HTML >



< / Obligation>

< / Obligations>

< / Results>

< /结果>

< /响应>

< / SOAP-ENV:正文>

< / SOAP-ENV:信封> / blockquote>

解决方案

我通过使用

 System.Xml.Linq解决了这个问题



使用 XDocument 加载XML文件,可以使用 Descendants 方法按名称导航节点。


This is my soap message.. I need how to retrieve

Quote:

AttributeAssignment

values as array using xdocument in c#

Quote:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope">
- <SOAP-ENV:Header>
- <Delivery>
  <Src>/AA/BB/CC</Src>
  <Dest>/AA/BB/CC/DD</Dest>
  <Reply />
  </Delivery>
  <MTXMLMsg MsgType="REPLY" />
  </SOAP-ENV:Header>
- <SOAP-ENV:Body>
- <Response>
- <Results xmlns="http://xacml.aa.web.com">
- <Result>
  <Decision>Permit</Decision>
- <Status>
  <StatusCode Value="urn:oasis:names:tc:xacml:1.0:status:ok" />
  </Status>
- <Obligations>
- <Obligation FulfillOn="Deny" ObligationId="PutInCache">
  <AttributeAssignment AttributeId="resource" DataType="http://www.w3.org/2001/XMLSchema#string">Appgrp:App: grp2</AttributeAssignment>
  </Obligation>
- <Obligation FulfillOn="Deny" ObligationId="PutInCache">
  <AttributeAssignment AttributeId="resource" DataType="http://www.w3.org/2001/XMLSchema#string">Appgrp:App: grp1</AttributeAssignment>
  </Obligation>
- <Obligation FulfillOn="Deny" ObligationId="PutInCache">
  <AttributeAssignment AttributeId="resource" DataType="http://www.w3.org/2001/XMLSchema#string">Appgrp:App:grp1: subgrp1</AttributeAssignment><pre><pre lang="text"><pre lang="HTML">


</Obligation>
</Obligations>
</Results>
</Result>
</Response>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>/blockquote>

解决方案

I solved this problem by using

System.Xml.Linq


Using an XDocument to load your XML file allows you to navigate the nodes by name using the Descendants method.


这篇关于如何在soap消息中提取特定的xml标记值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆