日期:2014-05-17 浏览次数:20905 次
<?xml version="1.0" encoding="UTF-8"?> <PropDataBucket name="navisworks_df_floor_cicle" version="1.0"> <PropDataRow name="smoke" index="0" type="custom"> <target name="properties"> <property name="floortype" value= "circular"></property> <property name="length" value= ""></property> </target> </PropDataRow> <PropDataRow name="navisworks_df_floor_rectangular_01" index="1" type=""> <target name="properties"> <property name="floortype" value="rectangular" /> <property name="length" value="1000.00" /> </target> </PropDataRow> </PropDataBucket>
using System; using System.Xml; namespace ConsoleApplication5 { class Class1 { [STAThread] static void Main(string[] args) { myDoc.Load("F:\\xmlReader1\\test.xml"); //string Test22 = myDoc.SelectSingleNode("//PropDataBucket[name='PropDataBucket']").ChildNodes.Item(1).OuterXml; string Test22 = myDoc.SelectSingleNode("//PropDataBucket[name='PropDataBucket']").ChildNodes.Item(1).OuterXml; Console.WriteLine(Test22); //XmlNode root = myDoc.DocumentElement; //Console.WriteLine(root); //Console.ReadKey(); } } }
<?xml version="1.0" encoding="utf-8" ?> <root> <Temple> <Temple_Name Temple_Value="0">摸版1</Temple_Name> <Temle_Content> <Temple_Title>摸版1</Temple_Title> <Temple_Event>事件名称</Temple_Event> <Temple_Date>事件</Temple_Date> </Temle_Content> </Temple> <Temple> <Temple_Name Temple_Value="1">摸版2</Temple_Name> <Temle_Content> <Temple_Title>摸版2</Temple_Title> <Temple_Event>事件名称</Temple_Event> <Temple_Date>事件</Temple_Date> </Temle_Content> </Temple> <Temple> <Temple_Name Temple_Value="2">摸版3</Temple_Name> <Temle_Content> <Temple_Title>摸版3</Temple_Title> <Temple_Event>事件名称</Temple_Event> <Temple_Date>事件</Temple_Date> </Temle_Content> </Temple> <Temple> <Temple_Name Temple_Value="3">other</Temple_Name> <Temle_Content> </Temle_Content> </Temple> </root>
------解决方案--------------------
为什么不用 LINQ to XML?
------解决方案--------------------
string Test22 = myDoc.SelectSingleNode("//PropDataBucket[name='PropDataBucket']").ChildNodes.Item(1).OuterXml; Console.WriteLine(Test22);
------解决方案--------------------