现在我有这样一个xml文档如下:
<?xml version="1.0" encoding="utf-8" ?>
<wfs:WFS_Capabilities version='1.1.0' 
  xsi:schemaLocation='http://www.opengis.net/gml http://schemas.opengis.net/gml/3.1.1/base/gml.xsd http://www.opengis.net/ogc http://schemas.opengis.net/filter/1.1.0/filter.xsd http://www.opengis.net/ows http://schemas.opengis.net/ows/1.0.0/owsAll.xsd http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd' 
xmlns:wfs='http://www.opengis.net/wfs' 
xmlns:ogc='http://www.opengis.net/ogc' 
xmlns:gml='http://www.opengis.net/gml' 
xmlns:ows='http://www.opengis.net/ows' 
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' 
xmlns:xlink='http://www.w3.org/1999/xlink' 
xmlns:AutoAddWFS='http://10.0.4.89/arcgis/services/AutoAddWFS/MapServer/WFSServer?'>
<ows:ServiceIdentification>
<ows:Title>AutoAddWFS</ows:Title>
<ows:Abstract></ows:Abstract>
<ows:Keywords>
<ows:Keyword></ows:Keyword>
</ows:Keywords>
<ows:ServiceType>WFS</ows:ServiceType>
<ows:ServiceTypeVersion>1.1.0</ows:ServiceTypeVersion>
<ows:Fees></ows:Fees>
<ows:AccessConstraints></ows:AccessConstraints>
</ows:ServiceIdentification>
<ows:ServiceProvider>
<ows:ProviderName></ows:ProviderName>
<ows:ServiceContact>
<ows:IndividualName></ows:IndividualName>
<ows:PositionName></ows:PositionName>
<ows:ContactInfo>
<ows:Phone>
<ows:Voice></ows:Voice>
<ows:Facsimile></ows:Facsimile>
</ows:Phone>
<ows:Address>
<ows:DeliveryPoint></ows:DeliveryPoint>
<ows:City></ows:City>
<ows:AdministrativeArea></ows:AdministrativeArea>
<ows:PostalCode></ows:PostalCode>
<ows:Country></ows:Country>
<ows:ElectronicMailAddress></ows:ElectronicMailAddress>
</ows:Address>
<ows:OnlineResource xlink:href='http://10.0.4.89/arcgis/services/AutoAddWFS/MapServer/WFSServer?'/>
<ows:HoursOfService></ows:HoursOfService>
<ows:ContactInstructions></ows:ContactInstructions>
</ows:ContactInfo>
</ows:ServiceContact>
</ows:ServiceProvider>
<ows:OperationsMetadata>
<ows:Operation name='GetCapabilities'>
<ows:DCP>
<ows:HTTP>
<ows:Get xlink:href='http://10.0.4.89/arcgis/services/AutoAddWFS/MapServer/WFSServer?'/>
<ows:Post xlink:href='http://10.0.4.89/arcgis/services/AutoAddWFS/MapServer/WFSServer'/>
</ows:HTTP>
</ows:DCP>
<ows:Parameter name='AcceptVersions'>
<ows:Value>1.1.0</ows:Value>
<ows:Value>1.0.0</ows:Value>
</ows:Parameter>
<ows:Parameter name='AcceptFormats'>
<ows:Value>text/xml</ows:Value>
</ows:Parameter>
</ows:Operation>
<ows:Operation name='DescribeFeatureType'>
<ows:DCP>
<ows:HTTP>
<ows:Get xlink:href='http://10.0.4.89/arcgis/services/AutoAddWFS/MapServer/WFSServer?'/>
<ows:Post xlink:href='http://10.0.4.89/arcgis/services/AutoAddWFS/MapServer/WFSServer'/>
</ows:HTTP>
</ows:DCP>
<ows:Parameter name='outputFormat'>
<ows:Value>text/xml; subType=gml/3.1.1/profiles/gmlsf/1.0.0/0</ows:Value>
</ows:Parameter>
</ows:Operation>
<ows:Operation name='GetFeature'>
<ows:DCP>
<ows:HTTP>
<ows:Get xlink:href='http://10.0.4.89/arcgis/services/AutoAddWFS/MapServer/WFSServer?'/>
<ows:Post xlink:href='http://10.0.4.89/arcgis/services/AutoAddWFS/MapServer/WFSServer'/>
</ows:HTTP>
</ows:DCP>
<ows:Parameter name='resultType'>
<ows:Value>results</ows:Value>
<ows:Value>hits</ows:Value>
</ows:Parameter>
<ows:Parameter name='outputFormat'>
<ows:Value>text/xml; subType=gml/3.1.1/profiles/gmlsf/1.0.0/0</ows:Value>
</ows:Parameter>
</ows:Operation>
<ows:ExtendedCapabilities>
<ows:Constraint name='serviceAxisOrderForSwappableSRS'>
<ows:Value>longitude,latitude</ows:Value>
</ows:Constraint>
</ows:ExtendedCapabilities>
</ows:OperationsMetadata>
<wfs:FeatureTypeList>
<wfs:FeatureType>
<wfs:Name>AutoAddWFS:continent</wfs:Name>
<wfs:Title>continent</wfs:Title>
<wfs:DefaultSRS>urn:ogc:def:crs:EPSG:6.9:4326</wfs:DefaultSRS>
<wfs:OutputFormats>
<wfs:Format>text/xml; subType=gml/3.1.1/profiles/gmlsf/1.0.0/0</wfs:Format>
</wfs:OutputFormats>
<ows:WGS84BoundingBox>
<ows:LowerCorner>-180 -90</ows:LowerCorner>
<ows:UpperCorner>180 83.62359619140625</ows:UpperCorner>
</ows:WGS84BoundingBox>
</wfs:FeatureType>
</wfs:FeatureTypeList>
<ogc:Filter_Capabilities>
<ogc:Spatial_Capabilities>
<ogc:GeometryOperands>
<ogc:GeometryOperand>gml:Envelope</ogc:GeometryOperand>
<ogc:GeometryOperand>gml:Point</ogc:GeometryOperand>
<ogc:GeometryOperand>gml:Polygon</ogc:GeometryOperand>
<ogc:GeometryOperand>gml:LineString</ogc:GeometryOperand>
</ogc:GeometryOperands>
<ogc:SpatialOperators>
<ogc:SpatialOperator name='BBOX'/>
<ogc:SpatialOperator name='Equals'/>
<ogc:SpatialOperator name='Disjoint'/>
<ogc:SpatialOperator name='Intersects'/>
<ogc:SpatialOperator name='Crosses'/>
<ogc:SpatialOperator name='Touches'/>
<ogc:SpatialOperator name='Within'/>
<ogc:SpatialOperator name='Contains'/>
<ogc:SpatialOperator name='Overlaps'/>
</ogc:SpatialOperators>
</ogc:Spatial_Capabilities>
<ogc:Scalar_Capabilities>
<ogc:LogicalOperators/>
<ogc:ComparisonOperators>
<ogc:ComparisonOperator>EqualTo</ogc:ComparisonOperator>
<ogc:ComparisonOperator>NotEqualTo</ogc:ComparisonOperator>
<ogc:ComparisonOperator>LessThan</ogc:ComparisonOperator>
<ogc:ComparisonOperator>GreaterThan</ogc:ComparisonOperator>
<ogc:ComparisonOperator>LessThanEqualTo</ogc:ComparisonOperator>
<ogc:ComparisonOperator>GreaterThanEqualTo</ogc:ComparisonOperator>
<ogc:ComparisonOperator>Like</ogc:ComparisonOperator>
<ogc:ComparisonOperator>Between</ogc:ComparisonOperator>
<ogc:ComparisonOperator>NullCheck</ogc:ComparisonOperator>
</ogc:ComparisonOperators>
</ogc:Scalar_Capabilities>
<ogc:Id_Capabilities>
<ogc:EID/>
<ogc:FID/>
</ogc:Id_Capabilities>
</ogc:Filter_Capabilities>
</wfs:WFS_Capabilities>
现在使用下面的语句进行查询:
 this.xmlDoc = new System.Xml.XmlDocument();
 this.xmlDoc.Load(filePath);
 System.Xml.XmlNamespaceManager m = new System.Xml.XmlNamespaceManager(this.xmlDoc.NameTable);
 m.AddNamespace("ows", "http://www.opengis.net/ows");
 System.Xml.XPath.XPathNavigator node=this.xmlDoc.CreateNavigator();
 System.Xml.XPath.XPathNodeIterator iter = node.Select("/*/ows:ServiceIdentification/ows:Title|/*/ows:serviceidentification/ows:title|/*/OWS:SERVICEIDENTIFICATION/OWS:TITLE");--这里报错 需要命名空间管理器或 XsltContext。此查询具有前缀、变量或用户定义的函数
但我已经设置命名空间管理器了?
这是怎么回事,请教高手解答,在线等待》》》》

解决方案 »

  1.   

    System.Xml.XPath.XPathNodeIterator iter = node.Select("/*/ServiceIdentification/Title|/*/serviceidentification/title|/*/SERVICEIDENTIFICATION/TITLE");
      

  2.   

    改成这样,搞定
    this.xmlDoc = new System.Xml.XmlDocument();
    this.xmlDoc.Load(filePath);
    System.Xml.XmlNamespaceManager m = new System.Xml.XmlNamespaceManager(this.xmlDoc.NameTable);
    m.AddNamespace("ows", "http://www.opengis.net/ows");
    System.Xml.XPath.XPathNavigator node=this.xmlDoc.CreateNavigator();
    System.Xml.XPath.XPathNodeIterator iter = node.Select("/*/ows:ServiceIdentification/ows:Title|/* /ows:serviceidentification/ows:title|/*/OWS:SERVICEIDENTIFICATION /OWS:TITLE",m)
    谢谢大家