Results 1 to 5 of 5
Hello,
How can I pass xml data from memory or a variable to xmllint that expects a file as input?
Or does xmllint have the capabilities to read from stin ...
- 07-24-2010 #1Just Joined!
- Join Date
- Jul 2010
- Posts
- 4
Passing xml in mem or variable to xmllint
Hello,
How can I pass xml data from memory or a variable to xmllint that expects a file as input?
Or does xmllint have the capabilities to read from stin or a variable?
Thanks in advance
LA
- 07-24-2010 #2Just Joined!
- Join Date
- Jul 2010
- Posts
- 4
I came up with ( watch the - after xmllint )
but I want to use the --shell argument in xmllintCode:#!/bin/sh echo "<?xml version='1.0' encoding='UTF-8'?> <insertion> <mytag>123456</mytag> <mytag2>789</mytag2> </insertion>" | xmllint - | sed -ne 's/<[^>]\{1,\}>//gp'
So can I use something like
and still add info to stdin of xmllint?Code:echo cat /begin_mytag/end_mytag | xmllint -shell - | sed -ne 's/<[^>]\{1,\}>//gp'
- 07-27-2010 #3Just Joined!
- Join Date
- Jul 2010
- Posts
- 4
Maybe is my question unclear or should I post it in a different forum?
Any advise?
- 07-28-2010 #4Just Joined!
- Join Date
- Jul 2010
- Location
- Kolkata
- Posts
- 3
Hi,
Obviously you can do something like below in command prompt:
cat <file_name> | xmllint - | sed -ne 's/<[^>]\{1,\}>//gp'
for examlple:
cat test.xml | xmllint - | sed -ne 's/<[^>]\{1,\}>//gp'
But I am confused why do you want to use --shell option
Please let me know if you have any questions.
- 07-28-2010 #5Just Joined!
- Join Date
- Jul 2010
- Posts
- 4
Thanks for your time.
The problem is I need both, with --shell/cat I supply the filter and with - I supply the xml .
I need the combination of 'XML in memory or variable' passed to xmllint with the - option and the filter via the --shell option.
The filter is 'cat /begin_mytag/end_mytag'
and the xml value is in a variable
"<?xml version='1.0' encoding='UTF-8'?>
<insertion>
<mytag>123456</mytag>
<mytag2>789</mytag2>
</insertion>"
So far as I my knowledge goes, I don't know how to use both.


Reply With Quote