Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   XML (http://www.velocityreviews.com/forums/f32-xml.html)
-   -   Trasformare un testo in XML (http://www.velocityreviews.com/forums/t169043-trasformare-un-testo-in-xml.html)

RobynSH 03-24-2005 06:58 PM

Trasformare un testo in XML
 
Ho una vecchia procedura dalla quale vorrei poter generare un file XML.
L'output che ho a disposizione è il seguente:

=start-text=======================================
0:@SEDDES,0035|@SEDAGG,0030|@SEDIND,0030|@SEDIN2,0 030|@SEDCAP,0005|@SEDLOC,0030|
@SEDPRO,0003|@NUMDOC,0007|@DATADO,0010|@CLFPIV,001 6|
1:@ARTDES,0040|@CODUMS,0002|@QTAMOV,0007|@PRZBAS,0 011|@VALDET,0012|
2:@TOTIMP,0012|@ALIQ01,0005|@TOTIVA,0012|@PAGDES,0 030|@TOTDOC,0012|@TOTEUR,0012|
0:BIANCHI MARCO S.P.A.||Via Attilio
Sorti, 12||46123|Firenze
|FI |*******|24/03/2005|IT 02150140545 |
1:ARTICOLO DIMOSTRATIVO|N.| 10 | 1,500|15,
00|
1:A|CF| 2 | 10,000|20,
00|
1:Prova|NR| 10 | 5,000|50,
00|
1:Prova in.|NR| 100 | 560,000|*O
|
1:libero| || 1,000| 560,00|
1:$$|
1:*O=Merce in omaggio: Valore EUR 56.000,00 $$|
2: 5.645,00|20,00| 1.129,00|RIMESSA DIRETTA| 6.774,00|
3,50|
=end-text=======================================

In sostanza il file di input è:
- Definizione nomi e lunghezza variabili (0,1,2,.... sono i livelli)
- Definizione contenuti delle variabili (livello + valori separati da |)

Vorrei ottenere una cosa del genere (con un awk, sed o similare):

<root>
<definizione>
<livello id="0">
<variabile id="SEDDES" len="35"/>
<variabile id="SEDAGG" len="30"/>
...
<variabile id="SEDLOC" len="30"/>
</livello>
<livello id="1">
<variabile id="ARTDES" len="40"/>
...
</livello>
...
</definizione>
<valori>
<livello id="0">
<valore id="SEDDES">BIANCHI MARCO S.P.A.</valore>
...
<valore id="SEDLOC">Firenze</valore>
</livello>
....
</valori>
</root>

Larry 03-25-2005 12:10 AM

Re: Trasformare un testo in XML
 
In article <8f06aa0.0503241058.71e8b333@posting.google.com> ,
robynsh@gmail.com (RobynSH) wrote:

> Ho una vecchia procedura dalla quale vorrei poter generare un file XML.
> L'output che ho a disposizione è il seguente:


Could you in present days speak English, please?

RobynSH 03-25-2005 08:47 AM

Re: Trasformare un testo in XML
 
Need to obtain an XML file from the following text file:
=start-text=======================================
0:@SEDDES,0035|@SEDAGG,0030|@SEDIND,0030|@SEDIN2,0 030|@SEDCAP,0005|@SEDLOC,0030|
@SEDPRO,0003|@NUMDOC,0007|@DATADO,0010|@CLFPIV,001 6|
1:@ARTDES,0040|@CODUMS,0002|@QTAMOV,0007|@PRZBAS,0 011|@VALDET,0012|
2:@TOTIMP,0012|@ALIQ01,0005|@TOTIVA,0012|@PAGDES,0 030|@TOTDOC,0012|@TOTEUR,0012|
0:BIANCHI MARCO S.P.A.||Via Attilio
Sorti, 12||46123|Firenze
|FI |*******|24/03/2005|IT 02150140545 |
1:ARTICOLO DIMOSTRATIVO|N.| 10 | 1,500|15,
00|
1:A|CF| 2 | 10,000|20,
00|
1:Prova|NR| 10 | 5,000|50,
00|
1:Prova in.|NR| 100 | 560,000|*O
|
1:libero| || 1,000| 560,00|
1:$$|
1:*O=Merce in omaggio: Valore EUR 56.000,00 $$|
2: 5.645,00|20,00| 1.129,00|RIMESSA DIRETTA| 6.774,00|
3,50|
=end-text=======================================

I would an XML like this:

<root>
<definizione>
<livello id="0">
<variabile id="SEDDES" len="35"/>
<variabile id="SEDAGG" len="30"/>
...
<variabile id="SEDLOC" len="30"/>
</livello>
<livello id="1">
<variabile id="ARTDES" len="40"/>
...
</livello>
...
</definizione>
<valori>
<livello id="0">
<valore id="SEDDES">BIANCHI MARCO S.P.A.</valore>
...
<valore id="SEDLOC">Firenze</valore>
</livello>
....
</valori>
</root>

The text file contains a level number (first char in each line), in
the top there is the name of variable (SEDDES,SEDLOC,....) of each
level. Followed by the content of variables.


All times are GMT. The time now is 04:00 AM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57