Solved

xmllint on solaris

Posted on 2013-05-31
4
1,100 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

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…
Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses

617 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