xml - Search only childs and specifics grandchildren -


i'm looking expression xapth pass @ 2 level : childs nodes , "specifics grandchildren nodes" :

for instance :

<nodelevel_1>    <nodelevel_1.1 value="a" />    <nodelevel_1.2 value="b" />    <nodelevel_1.3>      <nodelevel_1.3.1 value="c" />   </nodelevel_1.3>  </nodelevel_1>  <nodelevel_2>    .... 

here im trying reach attribute: nodelevel_1.1/@value , nodelevel_1.3.1/@value

but without pass nodelevel_1.2/@value.

i tried use : descendant::nodelevel1/@value xpath got @value attribute of nodelevel_1.2 , don't want this.

is there way manage case xpath ? thanks.

you can check tag name not equal nodelevel_1.2.

tested using xmllint:

$ cat input.xml <nodelevel_1>   <nodelevel_1.1 value="a" />   <nodelevel_1.2 value="b" />   <nodelevel_1.3>      <nodelevel_1.3.1 value="c" />   </nodelevel_1.3> </nodelevel_1>  $ xmllint input.xml --xpath "//descendant::nodelevel_1/*[not(self::nodelevel_1.2)]/@value"  value="a" 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -