ASP.NET 1.1 - XPathNavigator等效的OuterXml

时间:2011-08-24 20:44:02

标签: equivalent asp.net-1.1 xpathnavigator outerxml

我正在使用Google Maps API在1.1中进行GeoCode查找,而我正在使用XPathNavigator对象进入砖墙。

我需要创建一个“子导航器”,以便我们可以对节点执行全局xpath搜索(例如// adr:PostalCodeNumber),因为xml架构会根据返回的Address的准确性而更改。

以下是一个示例回复:

    <kml xmlns="http://earth.google.com/kml/2.0"><Response>
     <name>2601 S. McKenzie Street </name>
      <Status>
       <code>200</code>
       <request>geocode</request>
      </Status>
      <Placemark id="p1">
       <address>2601 S McKenzie St, Foley, AL 36535, USA</address>
       <AddressDetails Accuracy="8" xmlns="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0"><Country><CountryNameCode>US</CountryNameCode><CountryName>USA</CountryName><AdministrativeArea><AdministrativeAreaName>AL</AdministrativeAreaName><Locality><LocalityName>Foley</LocalityName><Thoroughfare><ThoroughfareName>2601 S McKenzie St</ThoroughfareName></Thoroughfare><PostalCode><PostalCodeNumber>36535</PostalCodeNumber></PostalCode></Locality></AdministrativeArea></Country></AddressDetails>
<ExtendedData>
  <LatLonBox north="30.3733653" south="30.3706673" east="-87.6817548" west="-87.6844528" />
</ExtendedData>
<Point><coordinates>-87.6831038,30.3720163,0</coordinates></Point>
</Placemark>
<Placemark id="p2">
  <address>2601 S McKenzie St, Gulf Shores, AL 36542, USA</address>
  <AddressDetails Accuracy="8" xmlns="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0">
   <Country>  <CountryNameCode>US</CountryNameCode><CountryName>USA</CountryName><AdministrativeArea><AdministrativeAreaName>AL</AdministrativeAreaName><Locality><LocalityName>Gulf Shores</LocalityName><Thoroughfare><ThoroughfareName>2601 S McKenzie St</ThoroughfareName></Thoroughfare><PostalCode><PostalCodeNumber>36542</PostalCodeNumber></PostalCode></Locality></AdministrativeArea></Country></AddressDetails>
  <ExtendedData>
    <LatLonBox north="30.3093758" south="30.3066778" east="-87.6818443" west="-87.6845423" />
  </ExtendedData>
  <Point><coordinates>-87.6832047,30.3080269,0</coordinates></Point>
  </Placemark>
    </Response></kml>

我有这个2.0代码块,我正在尝试为OuterXml属性找到1.1等价物:

private XPathNavigator CreateSubNavigator(XPathNavigator nav)
    {
        using (StringReader reader = new StringReader(nav.OuterXml))
        {
            XPathDocument doc = new XPathDocument(reader);
            return doc.CreateNavigator();
        }
    }

我发现了这篇博客文章,但是到SerializableXPathNavigator源的链接已经死了。 =(

http://www.tkachenko.com/blog/archives/000155.html

请原谅我的无聊,但我如何使用自己的OuterXml方法编写自己的SerializableXPathNavigator类?

非常感谢你的帮助。

0 个答案:

没有答案