Skip reading xml elements that are inside a certain parent node

Gardens Regular

New Member
I am reading xml gps data using xmlreader.read(). I want to output all coordinate points that are not located within a line element. Below is contained within the file, and I want to exclude the coordinates listed.\[code\]<place> <desc>home</desc> <line> <coordinate>123,123,123</coordinate> <coordinate>1223,1223,22123</coordinate> </line></place>\[/code\]This is an example of a valid coordinate, that I want to output and process (all located within the same file):\[code\]<place> <desc>home</desc> <point> <coordinate>123,123,123</coordinate> </point></place>\[/code\]The difference is that one is part of a line object, and the other is a point. I currently have this code, and its grabbing everything.\[code\] while (lxmlReader.Read()) { if (lxmlReader.NodeType == XmlNodeType.Element) { if (lxmlReader.Name == "coordinate") { rtxtOutput.Text += "\r\nElement Name: " + lxmlReader.Name.ToString(); rtxtOutput.Text += " Value: " + lxmlReader.ReadInnerXml().ToString(); } } }\[/code\]
 
Back
Top