How can i get the parent of node text value in c#?

millspig

New Member
I have the following xml:\[code\]<?xml version="1.0"?><catalog> <book id="bk101"> <author>Gambardella, Matthew</author> <title>XML Developer's Guide</title> <genre>Computer</genre> <price>44.95</price> <publish_date>2000-10-01</publish_date> <description>An in-depth look at creating applications with XML.</description> </book> <book id="bk102"> <author>Ralls, Kim</author> <title>Midnight Rain</title> <genre>Fantasy</genre> <price>5.95</price> <publish_date>2000-12-16</publish_date> <description>A former architect battles corporate zombies, an evil sorceress, and her own childhood to become queen of the world.</description> </book></catalog>\[/code\]I found the title named "Midnight Rain". Now i want to know who is his parent so that i can use the \[code\]<author>\[/code\] text node. I tried something like:\[code\] var xpath = "../*[local-name() != 'title']"; xml.Load(xmlalltext); var xl1 = xml.SelectNodes(xpath); MessageBox.Show(xl1.Item(0).InnerText.ToString());\[/code\]
 
Back
Top