You are here: PSPad forum > English discussion forum > Re: Edit XML file

Re: Edit XML file

#1 Edit XML file

Posted by: ASydasd | Date: 03/24/2018 14:07 | IP: IP Logged

Hi, I've an XML file. All blocks are like this:

<DatiFatturaBodyDTR>
<DatiGenerali>
<TipoDocumento>TD11</TipoDocumento>
<Data>2017-08-04</Data>
<Numero>80056</Numero>
<DataRegistrazione>2017-08-07</DataRegistrazione>
</DatiGenerali>
<DatiRiepilogo>
<ImponibileImporto>2840.00</ImponibileImporto>
<DatiIVA>
<Imposta>624.80</Imposta>
<Aliquota>22.00</Aliquota>
</DatiIVA>
<EsigibilitaIVA>I</EsigibilitaIVA>
</DatiRiepilogo>
</DatiFatturaBodyDTR>

the tag "<TipoDocumento>" can be "TD01","TD02","TD03"...etc...

there is a way to insert a line (always the same) when "<TipoDocumento>" is valorized "TD11"?

something like:
IF <TipoDocumento> = "TD11" then INSERT (after </DatiIVA>) "<Natura>N6</Natura>".

The result should be:

<DatiFatturaBodyDTR>
<DatiGenerali>
<TipoDocumento>TD11</TipoDocumento>
<Data>2017-08-04</Data>
<Numero>80056</Numero>
<DataRegistrazione>2017-08-07</DataRegistrazione>
</DatiGenerali>
<DatiRiepilogo>
<ImponibileImporto>2840.00</ImponibileImporto>
<DatiIVA>
<Imposta>624.80</Imposta>
<Aliquota>22.00</Aliquota>
</DatiIVA>
<Natura>N6</Natura>
<EsigibilitaIVA>I</EsigibilitaIVA>
</DatiRiepilogo>
</DatiFatturaBodyDTR>

thank you!

Options: Reply | Quote | Up ^


#2 Re: Edit XML file

Posted by: Andreas | Date: 03/24/2018 18:19 | IP: IP Logged

I think you have to write a script in a language that supports an xml parser. Use the parser to modify your xml.

For JavaScript you maybe can use the DOMParser
developer.mozilla.org

Options: Reply | Quote | Up ^






Editor PSPad - freeware editor, © 2001 - 2018 Jan Fiala, Hosted by Webhosting TOJEONO.CZ, design by WebDesign PAY & SOFT, code Petr Dvořák, Privacy policy and GDPR