我正在使用 Google Maps API 在 1.1 中进行 GeoCode 查找,并且遇到了 XPathNavigator 对象的障碍。
我需要创建一个“子导航器”,以便我们可以对节点执行全局 xpath 搜索(例如 //adr:PostalCodeNumber),因为 xml 架构会根据返回的地址的准确性而改变。
这是一个示例响应:
<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 类?
非常感谢你的帮助。