xml - What is causing "junk after end of expression" error from xpath command? -
being far short of expert @ xml, i've been going through basic tutorials. there this one on xpath. luckily, linux setup has 'xpath' command works fine, until attributes.
xpath -e 'inventory/snack/chips@supplier' lemonade2.xml
gives error
parse of expression inventory/snack/chips@supplier failed - junk after end of expression: @supplier @ /usr/share/perl5/xml/xpath/parser.pm line 127.
my lemonade2.xml copy-pasted straight site. xpath works fine without '@supplier'.
maybe there's subtle missing character or something, or i've fat-fingered xpath ruin somehow. maybe tutorial old , uses obsolete xpath syntax? nah, break lot of existing code, wouldn't it? interference bash syntax? doing wrong?
accessing attributes path step in xpath, you're missing slash in front of attribute.
xpath -e 'inventory/snack/chips/@supplier' lemonade2.xml
is <inventory/>
outermost element? might want declare root in front of it:
xpath -e '/inventory/snack/chips@supplier' lemonade2.xml
Comments
Post a Comment