我有下面的一段代码,它接受一个 XMLDocument 对象和代码下面提到的格式的 xml。我想读取边界框中存在的 4 个标签的值:
南纬等
public static void readXML(XmlDocument document)
{
if (document == null)
{
throw new ArgumentNullException("document");
}
XmlNode specificNode = document.SelectSingleNode("/Response/ResourceSets/ResourceSet/Resources/Location/BoundingBox");
if (specificNode != null)
{
XmlNodeReader specificNodeReader = new XmlNodeReader(specificNode);
while (specificNodeReader.Read())
{
Console.WriteLine(specificNodeReader.Value);
}
}
}
xml 看起来像这样:
<?xml version="1.0" encoding="utf-8" ?>
- <Response xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/search/local/ws/rest/v1">
<Copyright>Copyright © 2012 Microsoft and its suppliers. All rights reserved. This API cannot be accessed and the content and any results may not be used, reproduced or transmitted in any manner without express written permission from Microsoft Corporation.</Copyright>
<BrandLogoUri>http://dev.virtualearth.net/Branding/logo_powered_by.png</BrandLogoUri>
<StatusCode>200</StatusCode>
<StatusDescription>OK</StatusDescription>
<AuthenticationResultCode>ValidCredentials</AuthenticationResultCode>
<TraceId>f651e16fe1204e12b848084d73f5148d|SINM001008|02.00.83.1900|SINMSNVM001115, SINMSNVM001124</TraceId>
- <ResourceSets>
- <ResourceSet>
<EstimatedTotal>1</EstimatedTotal>
- <Resources>
- <Location>
<Name><Some Name</Name>
- <Point>
<Latitude>47.640570402145386</Latitude>
<Longitude>-122.12937377393246</Longitude>
</Point>
- <BoundingBox>
<SouthLatitude>47.636707684574709</SouthLatitude>
<WestLongitude>-122.13701709146854</WestLongitude>
<NorthLatitude>47.644433119716062</NorthLatitude>
<EastLongitude>-122.12173045639638</EastLongitude>
</BoundingBox>
<EntityType>Address</EntityType>
</Location>
</Resources>
</ResourceSet>
</ResourceSets>
</Response>
有人可以指出,我在这里缺少什么?