> I am trying to retrieve title of the parent (post) by the id of the
> comment, Why doesn't this work?
[quoted text clipped - 14 lines]
> postId = xmlRoot.SelectSingleNode("root/post/
> comment[@id='101']").ParentNode.SelectSingleNode("title").InnerText
If you insist on selecting the root first then you need to use
xmlRoot.SelectSingleNode("post/comment[@id='101']")
Or you could use your expression but then you need to call
SelectSingleNode on the XmlDocument node e.g.
xmldoc.SelectSingleNode("root/post/comment[@id='101']")
And mixing XPath (SelectSingleNode) and DOM (ParentNode) is possible but
you do not gain anything, once you use XPath you could as well use .. to
access the parent with XPath e.g.
xmldoc.SelectSingleNode("root/post/comment[@id='101']/../title")

Signature
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/