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>
ここで私が見逃していることを誰かが指摘できますか?