How to ready deeply nested nodes

sandyumber

New Member
I got this kind of xml doc:\[code\]<class_table> <class_title> <class_name>SomeClassBla</class_name> </class_title> <fields> <field_name>DateTime _date</field_name> <field_name>string _posterName</field_name> <field_name>string _commentText</field_name> <field_name>bool _visible</field_name> </fields> <properties> <property_name>DateTime Date</property_name> <property_name>string PosterName</property_name> <property_name>string CommentText</property_name> <property_name>bool Visible</property_name> </properties> <methods /> <inheritance /></class_table><class_table> <class_title> <class_name>someAnotnerClass</class_name> </class_title> <fields> <field_name>int result</field_name> <field_name>string test</field_name> </fields> <properties> <property_name>string BlogPage</property_name> <property_name>string BlogPostPage</property_name> <property_name>string ErrorPage</property_name> <property_name>string ComingSoonPage</property_name> </properties> <methods> <method_name>string DateFormatter()</method_name> <method_name>string EncodeBase64()</method_name> <method_name>string DecodeBase64()</method_name> <method_name>string CategoriesFormatterTyped()</method_name> <method_name>string AddShareThisLink()</method_name> <method_name>string ShortenText()</method_name> <method_name>string CommentCountFormatter()</method_name> <method_name>string MtaShorten()</method_name> </methods> <inheritance /></class_table>\[/code\]So how i read for example all fields names for this 2 class_table nodes ? Its nested deep im tring to use this code:\[code\]XmlDocument readDiagramXml = new XmlDocument();readDiagramXml.Load(classDiagramFile);XmlNodeList classTables = readDiagramXml.GetElementsByTagName("class_table");foreach (XmlNode items in classTables){ string className = items["fields/fields_name"].InnerText; File.AppendAllText("A_class_diagram_test.txt", className + Environment.NewLine);}\[/code\]I got object referance error. All i want is to write values from each node to txt file with that format:Class name = SomeClassBlaField: DateTime _dateField: string _posterNameand so on
 
Top