J
Jeff Dege
I have a simple GML file I'm trying to parse using
XmlDocument.SelectNodes, and it's not working.
The GML:
<wfs:FeatureCollection xmlns:wfs="http://www.opengis.net/wfs">
<gml:featureMember
xmlns:gml="http://www.opengis.net/gml">
<feature:features
xmlns:feature="http://mapserver.gis.umn.edu/mapserver">
<feature:geometry>
[...]
</feature:geometry>
</feature:features>
</gml:featureMember>
</wfs:FeatureCollection>
My code:
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(...);
XmlNamespaceManager nsm = new XmlNamespaceManager(xmlDoc.NameTable);
nsm.AddNamespace("wfs", "http://www.opengis.net/wfs/");
nsm.AddNamespace("gml", "http://www.opengis.net/gml/");
nsm.AddNamespace("feature", "http://mapserver.gis.umn/edu/mapserver/");
XmlNodeList featureList = xmlDoc.SelectNodes("//feature:features", nsm);
The problem? featureList is empty - has zero nodes.
It's not that I don't have the namespaces loaded - when I had that wrong,
I got errors. I'm not getting errors. And I don't think I have the
xpath wrong - when I view the XML in FireFox, and bring up the XPath
Checker, an xpath of "//feature:features" highlights exactly the node I'd
have expected it to.
Any ideas?
--
Only justice, and not safety, is consistent with liberty, because safety
can be secured only by prior restraint and punishment of the innocent,
while justice begins with liberty and the concomitant presumption of
innocence and imposes punishment only after the fact.
- Jeffrey Snyder
XmlDocument.SelectNodes, and it's not working.
The GML:
<wfs:FeatureCollection xmlns:wfs="http://www.opengis.net/wfs">
<gml:featureMember
xmlns:gml="http://www.opengis.net/gml">
<feature:features
xmlns:feature="http://mapserver.gis.umn.edu/mapserver">
<feature:geometry>
[...]
</feature:geometry>
</feature:features>
</gml:featureMember>
</wfs:FeatureCollection>
My code:
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(...);
XmlNamespaceManager nsm = new XmlNamespaceManager(xmlDoc.NameTable);
nsm.AddNamespace("wfs", "http://www.opengis.net/wfs/");
nsm.AddNamespace("gml", "http://www.opengis.net/gml/");
nsm.AddNamespace("feature", "http://mapserver.gis.umn/edu/mapserver/");
XmlNodeList featureList = xmlDoc.SelectNodes("//feature:features", nsm);
The problem? featureList is empty - has zero nodes.
It's not that I don't have the namespaces loaded - when I had that wrong,
I got errors. I'm not getting errors. And I don't think I have the
xpath wrong - when I view the XML in FireFox, and bring up the XPath
Checker, an xpath of "//feature:features" highlights exactly the node I'd
have expected it to.
Any ideas?
--
Only justice, and not safety, is consistent with liberty, because safety
can be secured only by prior restraint and punishment of the innocent,
while justice begins with liberty and the concomitant presumption of
innocence and imposes punishment only after the fact.
- Jeffrey Snyder