我有以下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>
我想从中提取<Table>
元素。如果我使用xpath(/ *)我可以获得整个文档,但我无法找到从中提取某些元素的方法。甚至可以将XPath与WSDL XML一起使用吗?
编辑:我正在使用PostgreSQL xpath函数从XML列进行查询
答案 0 :(得分:1)
您可以使用XPath表达式选择此Table
元素,而不是处理该文档上各种命名空间的相当复杂的问题
xpath(/*/*/*/Table)
它会在每个第四级选择所有Table
元素。