Connecting Tech Pros Worldwide Help | Site Map

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

  #1  
Old October 16th, 2008, 05:15 PM
wengao
Guest
 
Posts: n/a
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


  #2  
Old October 18th, 2008, 04:45 PM
Joe Kesselman
Guest
 
Posts: n/a

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
  #3  
Old October 18th, 2008, 06:55 PM
Hermann Peifer
Guest
 
Posts: n/a

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 Threads
Thread Thread Starter Forum Replies Last Post
Starting University COSC and learning JAVA, advice please :D David Van D answers 1 February 4th, 2006 02:45 AM
PEP 350: Codetags Micah Elliott answers 20 October 1st, 2005 01:55 AM