我正在使用JQuery解析和XML。在这里你是一个样本...
<?xml version='1.0' encoding="ISO-8859-1" ?>
<wfs:FeatureCollection
xmlns:ms="http://mapserver.gis.umn.edu/mapserver"
xmlns:wfs="http://www.opengis.net/wfs"
xmlns:gml="http://www.opengis.net/gml"
xmlns:ogc="http://www.opengis.net/ogc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd
http://mapserver.gis.umn.edu/mapserver http://wms.pcn.minambiente.it/ogc?map=/ms_ogc/wfs/Numeri_Civici_2012.map&SERVICE=WFS&VERSION=1.0.0&REQUEST=DescribeFeatureType&TYPENAME=IN.NUMERICIVICI.2012&OUTPUTFORMAT=XMLSCHEMA">
<gml:boundedBy>
<gml:Box srsName="EPSG:4326">
<gml:coordinates>7.700007,44.802147 7.749396,44.849996</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<gml:featureMember>
<ms:IN.NUMERICIVICI.2012 fid="IN.NUMERICIVICI.2012.2728384">
<gml:boundedBy>
<gml:Box srsName="EPSG:4326">
<gml:coordinates>7.735138,44.810267 7.735138,44.810267</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<ms:boundary>
<gml:Point srsName="EPSG:4326">
<gml:coordinates>7.735138,44.810267</gml:coordinates>
</gml:Point>
</ms:boundary>
<ms:id>13800026457291</ms:id>
<ms:nome>Borgata Tetti Sotto</ms:nome>
<ms:civico>16</ms:civico>
<ms:istat>01004041</ms:istat>
<ms:cap>12030</ms:cap>
<ms:comune>CARAMAGNA PIEMONTE</ms:comune>
<ms:nome_ted> </ms:nome_ted>
<ms:provincia>CUNEO</ms:provincia>
<ms:regione>PIEMONTE</ms:regione>
</ms:IN.NUMERICIVICI.2012>
</gml:featureMember>
<gml:featureMember>
<ms:IN.NUMERICIVICI.2012 fid="IN.NUMERICIVICI.2012.2736621">
<gml:boundedBy>
<gml:Box srsName="EPSG:4326">
<gml:coordinates>7.735397,44.812403 7.735397,44.812403</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<ms:boundary>
<gml:Point srsName="EPSG:4326">
<gml:coordinates>7.735397,44.812403</gml:coordinates>
</gml:Point>
</ms:boundary>
<ms:id>13800026457290</ms:id>
<ms:nome>Borgata Tetti Sotto</ms:nome>
<ms:civico>25</ms:civico>
<ms:istat>01004041</ms:istat>
<ms:cap>12030</ms:cap>
<ms:comune>CARAMAGNA PIEMONTE</ms:comune>
<ms:nome_ted> </ms:nome_ted>
<ms:provincia>CUNEO</ms:provincia>
<ms:regione>PIEMONTE</ms:regione>
</ms:IN.NUMERICIVICI.2012>
</gml:featureMember>
我正在使用此表示法来提取标记值
$this.find('ms\\:nome, nome').text()
一切正常。
我不知道如何提取嵌套在点标记
下的标记坐标的值 <gml:Point srsName="EPSG:4326">
<gml:coordinates>7.735397,44.812403</gml:coordinates>
</gml:Point>
有什么建议吗?
非常感谢!!
切萨雷
答案 0 :(得分:0)
会做这样的工作吗?
$xml.find('gml:Point').each(function () {
$this.find('gml:coordinates').text()
});
然后您可以将该数据插入变量或在表中显示
答案 1 :(得分:0)
我已经以这种方式解决了......
$this.find('gml\\:Point, Point').find('gml\\:coordinates, coordinates').text()
现在正在使用