Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1135
  • Last Modified:

xmllint on solaris

greetings, I am trying to grab a value out of an xml node using XMLLINT.  my problem is that in Solaris 10, xmllint --xpath option does not exist.  I am not allowed to upgrade libxml to get that option.

To that end, I'm doing the cat function to get the value I'm looking for.

I'm trying the example in: http://stackoverflow.com/questions/11611385/get-value-from-an-attribute-using-xmllint

test=$(echo 'cat //body/value/@name' | xmllint --shell "test.xml" | grep -v ">" | cut -f 2 -d "=" | tr -d \");
echo $test

my call is:
test = $(echo 'cat //*[local-name()='document']/*[local-name()='code']/@code' | xmllint --shell "af176493-5b64-4dcc-bd1a-e01517146737.xml" | grep -v ">" | cut -f 2 -d "=" | tr -d \");
echo$test

now, if I manually go into xmllint --shell "af176493-5b64-4dcc-bd1a-e01517146737.xml"
and run: cat //*[local-name()='document']/*[local-name()='code']/@code

I get my value...no problem.

But if I put it in the script as the call, I get no value.
help?  Thanks.
0
Evan Cutler
Asked:
Evan Cutler
  • 2
  • 2
1 Solution
 
woolmilkporcCommented:
I don't know much abour xmllint, but these spaces around " = " are wrong:

Correct syntax:

Test=$(echo 'cat .. ...
...
echo $Test


Please note the uppercase "T"in "Test". "test" is a shell builtin, you should not use this name for variables in order to avoid confusion.
0
 
Evan CutlerAuthor Commented:
thanks...I get that...i was manually typing that in.  I need an xmllint guy.  

if I run this in a prompt:
echo 'cat //*[local-name()='document']/*[local-name()='code']/@code' | xmllint --shell "af176493-5b64-4dcc-bd1a-e01517146737.xml" | grep -v ">" | cut -f 2 -d "=" | tr -d \"

it returns nothing.

but if I do it in a shell...it returns my value.
THanks.
0
 
woolmilkporcCommented:
The single quotes around 'document' and 'code' might be a problem since the whole command is also surrounded by single quotes.

Try double quotes:

Test=$(echo "cat //*[local-name()='document']/*[local-name()='code']/@code" | xmllint ...
0
 
Evan CutlerAuthor Commented:
He Shoots, He Scores!!!
Thanks very much.  That was it.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now