Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: Getting the parent when the child doesn't exist [Thread Next] Re: Getting the parent when the child doesn't existTo: NULL Date: 3/3/2009 8:23:00 PM Jeroen Mostert wrote: > Greg Collins wrote: >> I'm posting this to both the XSL and C# newsgroups because it spans both. >> >> I have an XPath passed to me that starts at the root node and goes >> down to a table row node. From this XPath I was grabbing the table >> node by appending a "/.." to the end of the XPath. >> >> While this technique works great when the row exists, if the row does >> not exist, I can no longer identify the table node. >> > I don't mean to be overly simplistic, but why don't you just use the > XPath to navigate to the table node and then use the DOM (in an > XPathNavigator, or whatever other guise) to conditionally navigate up? > Do you have to stuff it in a single XPath expression? > Wait, I fail at reading -- you want to find the parent node when the child node doesn't exist (that particular expression isn't meaningful, but at least now I get what you mean). Well, I don't mean to be a spoilsport, but there's no guarantee you can get at a "parent node" at all in this case, is there? You can't navigate to a node based on its relation to a node that doesn't exist. Manipulating the XPath expression that points at the child node won't always work unless you can really guarantee that the XPath expression will be strictly hierarchical. Finding what would have been the parent node of "id('test')" had it existed, for example, is a tad tricky. -- J. | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
