如何在ruby中解析SOAP XML?

时间:2011-09-27 11:42:21

标签: ruby parsing soap

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="https://extranet.mcs.be/DEV_QUALITY_API/modules/quality/services/soap/quality.php"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
 <ns1:getQuestionnairesListResponse>
  <return SOAP-ENC:arrayType="ns1:QuestionnaireListItem[34]"
   xsi:type="ns1:ArrayOfQuestionnaireListItem">
   <item xsi:type="ns1:QuestionnaireListItem">
    <ID xsi:type="xsd:string">0000000022</ID>
    <Code xsi:type="xsd:string">Interest PubTransp</Code>
    <Reference xsi:type="xsd:string">Check Employees Interest in Public
     Transport</Reference>
   </item>
   <item xsi:type="ns1:QuestionnaireListItem">
    <ID xsi:type="xsd:string">0000000008</ID>
    <Code xsi:type="xsd:string">CS SRE North 2003</Code>
    <Reference xsi:type="xsd:string">Customer Satisfaction SRE North 2003</Reference>
   </item>
   <item xsi:type="ns1:QuestionnaireListItem">
    <ID xsi:type="xsd:string">0000000006</ID>
    <Code xsi:type="xsd:string">CS SRE South 2003</Code>
    <Reference xsi:type="xsd:string">Customer Satisfaction SRE South 2003</Reference>
   </item>
.
.
.

我想解析上面的soap String(我实际上想从上面的soap中获取项目)。我怎么能这样做?

1 个答案:

答案 0 :(得分:3)

有一个名为Savon的gem,专门用于处理Ruby中的SOAP。

the web site上有很好的文档,一旦你研究了这些文档,并且有更具体的问题,我相信我们可以帮助你。