Solved

xmllint on solaris

Posted on 2013-05-31
4
1,067 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Sed question 2 104
how awk substr works and also how index works in inside substr? 4 117
shell script 2 38
Powershell Timeout - Exchange 3 74
Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
Background Still having to process all these year-end "csv" files received from all these sources (including Government entities), sometimes we have the need to examine the contents due to data error, etc... As a "Unix" shop, our only readily …
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.

821 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