XML ノードからすべてのPit
XML 要素を取得しようとしています。Drainage_String
私の問題:ノードからすべてのPit
要素を取得しようとすると、XMLNodeList は常に空になります。ノードには 2 つの要素が含まれていることがわかっているPit
ため、2 つのノード要素を含める必要があります。
何がうまくいかないのですか?
XmlDocument xdoc = new XmlDocument();
xdoc.Load(xmlFilePath);
XmlNodeList xNodes = xdoc.DocumentElement.GetElementsByTagName("string_drainage");
foreach (XmlNode dStr in xNodes) {
XmlNodeList pits = dStr.SelectNodes("pit");
MessageBox.Show("Num: "+pits.Count.ToString(), "Number");
// always outputs "Num: 0"
}
私が使用しているサンプルデータ:
<string_drainage>
<pit>
<name>MH. </name>
<ip>0</ip>
<ratio>0</ratio>
<x>212908.89268569</x>
<y>612015.26122586</y>
<z>80.62414621</z>
</pit>
</string_drainage>
詳細データ:
<?xml version="1.0"?>
<xml12d xmlns="http://www.12d.com/schema/xml12d-10.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" language="English" version="1.0" date="2013-08-27" time="16:33:14" xsi:schemaLocation="http://www.12d.com/schema/xml12d-10.0 http://www.12d.com/schema/xml12d-10.0/xml12d.xsd">
<meta_data>
<units>
<metric>
<linear>metre</linear>
<area>square metre</area>
<volume>cubic metre</volume>
<temperature>celsius</temperature>
<pressure>millibars</pressure>
<angular>decimal degrees</angular>
<direction>decimal degrees</direction>
</metric>
</units>
<application>
<name>12d Model</name>
<manufacturer>12d Solutions Pty Ltd</manufacturer>
<manufacturer_url>www.12d.com</manufacturer_url>
<application>12d Model 10.0C1j</application>
<application_build>10.1.10.22</application_build>
<application_path>C:\Program Files\12d\12dmodel\10.00\nt.x64\12d.exe</application_path>
<application_date_gmt>24-Jul-2013 02:18:30</application_date_gmt>
<application_date>24-Jul-2013 12:18:30</application_date>
<project_name>mjkhjk</project_name>
<project_guid>{30A05217-706A-41c1-AF53-0D1A0975A5D0}</project_guid>
<project_folder>C:\12djobs\mjkhjk</project_folder>
<client>12d Training - NSW</client>
<dongle>572d471062</dongle>
<environment/>
<env4d>C:\12d\10.00\user\env.4d</env4d>
<user>Sam Zielke-Ryner</user>
<export_file_name>Tttt.xml</export_file_name>
<export_date_gmt>27-Aug-2013 06:33:14</export_date_gmt>
<export_date>27-Aug-2013 16:33:14</export_date>
</application>
</meta_data>
<comments>
<manufacturer>12d Solutions Pty Ltd</manufacturer>
<manufacturer_url>www.12d.com</manufacturer_url>
<application>12d Model 10.0C1j</application>
<application_build>10.1.10.22</application_build>
<application_path>C:\Program Files\12d\12dmodel\10.00\nt.x64\12d.exe</application_path>
<application_date_gmt>24-Jul-2013 02:18:30</application_date_gmt>
<application_date>24-Jul-2013 12:18:30</application_date>
<export_file_name>Tttt.xml</export_file_name>
<export_date_gmt>27-Aug-2013 06:33:14</export_date_gmt>
<export_date>27-Aug-2013 16:33:14</export_date>
</comments>
<string_drainage>
<name/>
<time_created>29-Jul-2013 02:02:03</time_created>
<time_updated>29-Jul-2013 02:02:11</time_updated>
<outfall>null</outfall>
<flow_direction>1</flow_direction>
<use_pit_con_points>false</use_pit_con_points>
<data_3d>
<p>212908.89268569 612015.26122586 0</p>
<p>212715.09268598 612007.24091243 84.20896044</p>
</data_3d>
<pit>
<name>MH. </name>
<type>CONC COVER</type>
<road_name/>
<road_chainage>null</road_chainage>
<diameter>1.1</diameter>
<con_point_mode>Points</con_point_mode>
<floating>true</floating>
<hgl>null</hgl>
<chainage>0</chainage>
<ip>0</ip>
<ratio>0</ratio>
<x>212908.89268569</x>
<y>612015.26122586</y>
<z>80.62414621</z>
</pit>
<pit>
<name>MH. </name>
<type>CONC COVER</type>
<road_name/>
<road_chainage>null</road_chainage>
<diameter>1.1</diameter>
<con_point_mode>Points</con_point_mode>
<floating>true</floating>
<hgl>null</hgl>
<chainage>193.96588699</chainage>
<ip>1</ip>
<ratio>0</ratio>
<x>212715.09268598</x>
<y>612007.24091243</y>
<z>84.20896044</z>
</pit>
<pipe>
<name>A</name>
<type>PVC</type>
<diameter>0.15</diameter>
<nominal_diameter>0.15</nominal_diameter>
<us_level>77.38411559</us_level>
<ds_level>79.32377446</ds_level>
<us_hgl>0</us_hgl>
<ds_hgl>0</ds_hgl>
<flow_velocity>0</flow_velocity>
<flow_volume>0</flow_volume>
<attributes>
<real>
<name>nominal diameter</name>
<value>0.15</value>
</real>
<real>
<name>calculated critical cover chainage</name>
<value>4.31482574</value>
</real>
</attributes>
</pipe>
</string_drainage>
</xml12d>