[英]Extract list of objects from WSDL XML with XPath
I have the following XML: 我有以下XML:
<?xml version="1.0" encoding="UTF-8"?>
<DataSet xmlns="http://MRCS/">
<xs:schema id="Estacoes" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="Estacoes" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="Table">
<xs:complexType>
<xs:sequence>
<xs:element name="NomeEstacao" type="xs:string" minOccurs="0"/>
<xs:element name="CodEstacao" type="xs:string" minOccurs="0"/>
<xs:element name="Bacia" type="xs:string" minOccurs="0"/>
<xs:element name="SubBacia" type="xs:decimal" minOccurs="0"/>
<xs:element name="Operadora" type="xs:string" minOccurs="0"/>
<xs:element name="Responsavel" type="xs:string" minOccurs="0"/>
<xs:element name="Municipio-UF" type="xs:string" minOccurs="0"/>
<xs:element name="Latitude" type="xs:decimal" minOccurs="0"/>
<xs:element name="Longitude" type="xs:decimal" minOccurs="0"/>
<xs:element name="Altitude" type="xs:decimal" minOccurs="0"/>
<xs:element name="CodRio" type="xs:decimal" minOccurs="0"/>
<xs:element name="NomeRio" type="xs:string" minOccurs="0"/>
<xs:element name="Origem" type="xs:string" minOccurs="0"/>
<xs:element name="StatusEstacao" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<Estacoes xmlns="">
<Table diffgr:id="Table1" msdata:rowOrder="0">
<NomeEstacao>GUARAPUAVA - COLÉGIO AGRICOLA</NomeEstacao>
<CodEstacao>02551010</CodEstacao>
<Bacia>6</Bacia>
<SubBacia>65</SubBacia>
<Operadora>00067 - IAPAR - IAPAR</Operadora>
<Responsavel>00067 - IAPAR - IAPAR</Responsavel>
<Municipio-UF>GUARAPUAVA-PR</Municipio-UF>
<Latitude>-25.36470</Latitude>
<Longitude>-51.49690</Longitude>
<Altitude>1045.00</Altitude>
<CodRio>0</CodRio>
<NomeRio/>
<Origem>ANA/SIVAM</Origem>
<StatusEstacao>Ativo</StatusEstacao>
</Table>
</Estacoes>
</diffgr:diffgram>
</DataSet>
From which i want to extract the <Table>
element. 我要从中提取
<Table>
元素。 If i use xpath(/*) i can get the entire document, but i can't figure out a way to extract certain elements from it. 如果我使用xpath(/ *),我可以获取整个文档,但是我找不到从中提取某些元素的方法。 Is it even possible to use XPath with WSDL XMLs?
甚至可以将XPath与WSDL XML一起使用?
EDIT: i am using PostgreSQL xpath function to query from a XML column 编辑:我正在使用PostgreSQL xpath函数从XML列查询
Instead of handling the quite complex issue with the various namespaces on that document you can select this Table
element with the XPath expression 可以使用XPath表达式选择此
Table
元素,而不用处理该文档中各种名称空间的相当复杂的问题。
xpath(/*/*/*/Table)
It selects all Table
elements on every fourth level. 它每四个级别选择所有
Table
元素。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.