如何使用PHP

时间:2015-09-05 10:28:42

标签: php soap xml-parsing namespaces

我想用Namespace解析DOM类型的XML。以下是XML的格式。

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 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:Header/>
   <SOAP-ENV:Body>
      <ns:ShowInventoryValue releaseID="" xmlns:ns="http://www.xxxx.com/oxit/oagis">
         <ns:ApplicationArea>
            <ns:CreationDateTime/>
         </ns:ApplicationArea>
         <ns:DataArea>
            <ns:Show/>
            <ns:InventoryValue>
               <ns:InventoryValueHeader>
                  <ns:Party role="WarehouseParty">
                     <ns:PartyIDs>
                        <ns:ID schemeName="PartyTypeNumber">001</ns:ID>
                        <ns:ID schemeName="PartyNumber">000123</ns:ID>
                        <ns:ID schemeName="PartySubNumber">000123</ns:ID>
                     </ns:PartyIDs>
                     <ns:Name sequence="1">W90</ns:Name>
                     <ns:Name sequence="2">India</ns:Name>
                  </ns:Party>
                  <ns:CustomerParty>
                     <ns:PartyIDs>
                        <ns:ID schemeName="EAN13">3938243</ns:ID>
                     </ns:PartyIDs>
                  </ns:CustomerParty>
               </ns:InventoryValueHeader>
               <ns:InventoryValueLine>
                  <ns:Item>
                     <ns:ItemID>
                        <ns:ID schemeName="article">1101960</ns:ID>
                     </ns:ItemID>
                     <ns:Specification>
                        <ns:Property>
                           <ns:NameValue name="centralized">Y</ns:NameValue>
                        </ns:Property>
                     </ns:Specification>
                  </ns:Item>
                  <ns:Quantity unitCode="ST" type="InTransitSum">0</ns:Quantity>
                  <ns:Status>
                     <ns:Code name="availability"/>
                  </ns:Status>
                  <ns:OxLocalization>
                     <ns:Party role="WarehousePartyCAC">
                        <ns:PartyIDs>
                           <ns:ID schemeName="PartyTypeNumber">009</ns:ID>
                           <ns:ID schemeName="PartyNumber">00056</ns:ID>
                           <ns:ID schemeName="PartySubNumber">00056</ns:ID>
                        </ns:PartyIDs>
                        <ns:Name sequence="1">W90</ns:Name>
                        <ns:Name sequence="2">India</ns:Name>
                     </ns:Party>
                     <ns:OxQuantityAvailability>
                        <ns:OxAvailability type="value1">
                           <ns:TypedQuantity unitCode="ST">0</ns:TypedQuantity>
                        </ns:OxAvailability>
                        <ns:OxAvailability type="value2">
                           <ns:TypedQuantity unitCode="ST">0</ns:TypedQuantity>
                        </ns:OxAvailability>
                        <ns:OxAvailability type="value3">
                           <ns:TypedQuantity unitCode="ST">0</ns:TypedQuantity>
                        </ns:OxAvailability>
                        <ns:OxAvailability type="value4">
                           <ns:TypedQuantity>0</ns:TypedQuantity>
                        </ns:OxAvailability>
                        <ns:OxAvailability type="value5">
                           <ns:TypedQuantity>0</ns:TypedQuantity>
                        </ns:OxAvailability>
                        <ns:OxAvailability type="value6">
                           <ns:TypedQuantity>0</ns:TypedQuantity>
                        </ns:OxAvailability>
                        <ns:OxAvailability type="value7">
                           <ns:TypedQuantity>0</ns:TypedQuantity>
                        </ns:OxAvailability>
                        <ns:OxAvailability type="value8">
                           <ns:TypedQuantity>0</ns:TypedQuantity>
                        </ns:OxAvailability>
                     </ns:OxQuantityAvailability>
                  </ns:OxLocalization>
               </ns:InventoryValueLine>
               <ns:InventoryValueLine>
                  <ns:Item>
                     <ns:ItemID>
                        <ns:ID schemeName="article">1101960</ns:ID>
                     </ns:ItemID>
                     <ns:Specification>
                        <ns:Property>
                           <ns:NameValue name="centralized">Y</ns:NameValue>
                        </ns:Property>
                     </ns:Specification>
                  </ns:Item>
                  <ns:Quantity unitCode="ST" type="InTransitSum">0</ns:Quantity>
                  <ns:Status>
                     <ns:Code name="availability"/>
                  </ns:Status>
                  <ns:OxLocalization>
                     <ns:Party role="WarehousePartyCAC">
                        <ns:PartyIDs>
                           <ns:ID schemeName="PartyTypeNumber">009</ns:ID>
                           <ns:ID schemeName="PartyNumber">00056</ns:ID>
                           <ns:ID schemeName="PartySubNumber">00056</ns:ID>
                        </ns:PartyIDs>
                        <ns:Name sequence="1">W90</ns:Name>
                        <ns:Name sequence="2">India</ns:Name>
                     </ns:Party>
                     <ns:OxQuantityAvailability>
                        <ns:OxAvailability type="value1">
                           <ns:TypedQuantity unitCode="ST">0</ns:TypedQuantity>
                        </ns:OxAvailability>
                        <ns:OxAvailability type="value2">
                           <ns:TypedQuantity unitCode="ST">0</ns:TypedQuantity>
                        </ns:OxAvailability>
                        <ns:OxAvailability type="value3">
                           <ns:TypedQuantity unitCode="ST">0</ns:TypedQuantity>
                        </ns:OxAvailability>
                        <ns:OxAvailability type="value4">
                           <ns:TypedQuantity>0</ns:TypedQuantity>
                        </ns:OxAvailability>
                        <ns:OxAvailability type="value5">
                           <ns:TypedQuantity>0</ns:TypedQuantity>
                        </ns:OxAvailability>
                        <ns:OxAvailability type="value6">
                           <ns:TypedQuantity>0</ns:TypedQuantity>
                        </ns:OxAvailability>
                        <ns:OxAvailability type="value7">
                           <ns:TypedQuantity>0</ns:TypedQuantity>
                        </ns:OxAvailability>
                        <ns:OxAvailability type="value8">
                           <ns:TypedQuantity>0</ns:TypedQuantity>
                        </ns:OxAvailability>
                     </ns:OxQuantityAvailability>
                  </ns:OxLocalization>
               </ns:InventoryValueLine>
            </ns:InventoryValue>
         </ns:DataArea>
      </ns:ShowInventoryValue>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

在上面的XML中,我想解析ItemID和value1类型的数量。我无法在网上找到适当的资源来解析相同的资源。请帮我解决方案或提供参考链接以进行参考和解析。大多数在线资源都在讨论简单的xml解析。但我想解析这个棘手的XML。

0 个答案:

没有答案