Solved

xmllint on solaris

Posted on 2013-05-31
4
1,053 Views
Last Modified: 2013-05-31
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
Comment
Question by:Evan Cutler
  • 2
  • 2
4 Comments
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 39210675
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
 
LVL 9

Author Comment

by:Evan Cutler
ID: 39210680
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
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 500 total points
ID: 39210704
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
 
LVL 9

Author Closing Comment

by:Evan Cutler
ID: 39210713
He Shoots, He Scores!!!
Thanks very much.  That was it.
0

Featured Post

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question