Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries [Thread Prev] >Thread Next - Re: Getting the parent when the child doesn't exist Getting the parent when the child doesn't existTo: NULL Date: 3/3/2009 10:50:00 AM 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. In code, one might say, well just rip off everything past the last slash character. This won't work because I cannot guarantee that a filter is not being used. And there might be nested filters and "[" and "]" characters used in the filter as values. So what I need to find is a way to extrapolate the parent XPath from that which is passed in, but accounting for potential nested filters and [ ] characters used as filter values. Anyone got any ideas? Here's a sample test XPath: /ns:Root/ns:Branch[ns:Val1 = '[']/ns:Table[ns:Row/ns:Field1 = '[']/ns:Row[ns:Field2 = '[Test' and ns:Group1/ns:Field3[ns:Val2 = ']'] = '['] What I need to get from it is the following: /ns:Root/ns:Branch[ns:Val1 = '[']/ns:Table[ns:Row/ns:Field1 = '['] I also cannot count on a namespace existing on the nodes. It might not. Regex would be great (if even possible). Brute force works too. Thanks ahead of time for any help. -- Greg Collins Microsoft MVP Visit Braintrove at http://www.braintrove.com | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
