Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Re: XPath-Query should include also root [Thread Next] Re: XPath-Query should include also root (SOLUTION)To: NULL Date: 11/16/2007 2:07:00 AM Hello Anthony, > > I have to parse different partial XML-nodes. I want > > get root or a child node if it has a specified attribute. > > But I get only childs at the moment. How can I get > > also the root node if it has the attribute? > > > > Sample: > > > > a) > > <MyTag MyAttribute='true'>MyText</MyTag> > > > > b) > > <MyRoot> > > <MyTag MyAttribute='true'>MyText</MyTag> > > </MyRoot> > > > > c) > > <MyRoot> > > <MyParent> > > <MyTag MyAttribute='true'>MyText</MyTag> > > </MyParent> > > </MyRoot> > > > > How can I query a) and b) for the attribute > > MyAttribute ? > > > > Actually "//*[@MyAttribute]" works only for > > childs (b, c). But I need it also for a) in the same > > query like this expression : > > > > "Select the root or child or descendant which > > has an attribute MyAttribute". > > > > > > Try:- > > > //self::*[@MyAttribute] > > // is an abbreviation for /descendant-or-self::node() > > Therefore //* is /descendant-or-self::node()/child::* > > Hence this path can never select the root node. Thanks! ... :) ... it works, like exprected ... :) | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
