1
我的GeoServer響應:XML根節點屬性使用jQuery
<wfs:FeatureCollection xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ogc="http://www.opengis.net/ogc" xmlns:tiger="http://www.census.gov" xmlns:topp="http://www.openplans.org/topp" xmlns:wfs="http://www.opengis.net/wfs" xmlns:ows="http://www.opengis.net/ows" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sf="http://www.openplans.org/spearfish" xmlns:gml="http://www.opengis.net/gml" xmlns:GIS="http://softwarekitchengisdata.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" numberOfFeatures="0" timeStamp="2015-09-20T12:15:46.527Z" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd"/>
我想獲得numberOfFeatures。
我已經厭倦瞭如下解決方案,但不工作
xmlDoc = $.parseXML(data);
console.log(xmlDoc);
//tried this
console.log($(xmlDoc).filter(":first"));
//tried this
$(xmlDoc).find('wfs\\:FeatureCollection').attr('numberOfFeatures');
這裏是我的小提琴: http://jsfiddle.net/uftmnggw/