Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Trasformare un testo in XML

Reply
Thread Tools

Trasformare un testo in XML

 
 
RobynSH
Guest
Posts: n/a
 
      03-24-2005
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|
1rova|NR| 10 | 5,000|50,
00|
1rova 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>
 
Reply With Quote
 
 
 
 
Larry
Guest
Posts: n/a
 
      03-25-2005
In article <(E-Mail Removed)> ,
http://www.velocityreviews.com/forums/(E-Mail Removed) (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?
 
Reply With Quote
 
 
 
 
RobynSH
Guest
Posts: n/a
 
      03-25-2005
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|
1rova|NR| 10 | 5,000|50,
00|
1rova 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Different results parsing a XML file with XML::Simple (XML::Sax vs. XML::Parser) Erik Wasser Perl Misc 5 03-05-2006 10:09 PM
Selezionare un parte del testo di una "textarea" in asp FABRIZIO Javascript 0 12-06-2004 03:17 PM
Print XML parsing to JspWriter (out) Class org.xml.sax.helpers.NewInstance can not access a member of class javax.xml.parsers.SAXParser with modifiers "protected" Per Magnus L?vold Java 0 11-15-2004 02:27 PM
What XML technologies to learn first for "XML Processing" and "XML Mapping"? Bomb Diggy Java 0 07-28-2004 07:26 AM
Help on including one XML document within another XML document using XML Schemas Tony Prichard XML 0 12-12-2003 03:18 PM



Advertisments