Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - How to add multiple lines to an existing xml file? Can we do thefollowing way? [Thread Next] Re: How to add multiple lines to an existing xml file? Can we do thefollowing way?To: NULL Date: 10/18/2008 7:52:00 PM wengao wrote:
> xml ed -i <xpath> -t elem -n Value -v <value1> > -t elem -n Value -v <value2> > -t elem -n Value -v <value3> sample.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>
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
