Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


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

From: Hermann Peifer <peifer@---.-->
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>


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent