Connecting Tech Pros Worldwide Help | Site Map

How to add multiple lines to an existing xml file? Can we do thefollowing way?

wengao
Guest
 
Posts: n/a
#1: Oct 16 '08
xml ed -i <xpath-t elem -n Value -v <value1\
-t elem -n Value -v <value2\
-t elem -n Value -v <value3sample.xml


There was a complaint about the second one: I/O warning : failed to load
external entity "elem"

Any thoughts?

Thanks,
Wengao


Joe Kesselman
Guest
 
Posts: n/a
#2: Oct 18 '08

re: How to add multiple lines to an existing xml file? Can we do thefollowing way?


wengao wrote:
Quote:
xml ed -i <xpath-t elem -n Value -v <value1\
-t elem -n Value -v <value2\
-t elem -n Value -v <value3sample.xml
I'm not familiar with the command-line "xml" tool you're using. Check
its documentation?

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Hermann Peifer
Guest
 
Posts: n/a
#3: Oct 18 '08

re: How to add multiple lines to an existing xml file? Can we do thefollowing way?


wengao wrote:
Quote:
xml ed -i <xpath-t elem -n Value -v <value1\
-t elem -n Value -v <value2\
-t elem -n Value -v <value3sample.xml
>
>
There was a complaint about the second one: I/O warning : failed to load
external entity "elem"
>
Any thoughts?
>
Thanks,
Wengao
>
>
It looks like you have to repeat the full syntax, see below.

Hermann

$ cat table.xml # sample file from xmlstarlet manual

<?xml version="1.0"?>
<xml>
<table>
<rec id="1">
<numField>123</numField>
<stringField>String Value</stringField>
</rec>
<rec id="2">
<numField>346</numField>
<stringField>Text Value</stringField>
</rec>
<rec id="3">
<numField>-23</numField>
<stringField>stringValue</stringField>
</rec>
</table>
</xml>

$ xmlstarlet ed \
-i /xml/table/rec/numField -t elem -n Value -v value1 \
-i /xml/table/rec/numField -t elem -n Value -v value2 \
-i /xml/table/rec/numField -t elem -n Value -v value3 \
table.xml

<?xml version="1.0"?>
<xml>
<table>
<rec id="1">
<Value>value1</Value>
<Value>value2</Value>
<Value>value3</Value>
<numField>123</numField>
<stringField>String Value</stringField>
</rec>
<rec id="2">
<Value>value1</Value>
<Value>value2</Value>
<Value>value3</Value>
<numField>346</numField>
<stringField>Text Value</stringField>
</rec>
<rec id="3">
<Value>value1</Value>
<Value>value2</Value>
<Value>value3</Value>
<numField>-23</numField>
<stringField>stringValue</stringField>
</rec>
</table>
</xml>
Closed Thread


Similar .NET Framework bytes