You are here:  » parse more then 1 line

Support Forum



parse more then 1 line

Submitted by whmedia on Mon, 2007-12-10 22:25 in

Hello, I would like to parse more then 1 textline from a text file looks like this:

with the parser I get only the result of the first line.

can you help me...please

<WEAT_DATE>
10.12.2007
</WEAT_DATE>
<WEAT_TODAY_D>
Im Einflussbereich eines Tiefs über Mitteleuropa gelangen in den höheren Schichten feuchte Luftmassen in den Alpenraum.
</WEAT_TODAY_D>
<WEAT_TODAY_I>
Una depressione sull'Europa Centrale convoglia masse d'aria umida in quota verso le Alpi.
</WEAT_TODAY_I>

Submitted by support on Mon, 2007-12-10 22:35

Hi,

The snippet you have just posted is not quite valid XML, as there is no containing element. If this were valid XML, and there is only ever one record, you would expect a containing element, perhaps called "WEAT", so it would look like this:

<WEAT>
<WEAT_DATE>
10.12.2007
</WEAT_DATE>
<WEAT_TODAY_D>
Im Einflussbereich eines Tiefs über Mitteleuropa gelangen in den höheren Schichten feuchte Luftmassen in den Alpenraum.
</WEAT_TODAY_D>
<WEAT_TODAY_I>
Una depressione sull'Europa Centrale convoglia masse d'aria umida in quota verso le Alpi.
</WEAT_TODAY_I>
</WEAT>

However, if there is more than one record in the file, there should be two levels of containing elements in the XML, for example:

<WEATS>
  <WEAT>
    <WEAT_DATE>
    10.12.2007
    </WEAT_DATE>
    <WEAT_TODAY_D>
    Im Einflussbereich eines Tiefs über Mitteleuropa gelangen in den höheren Schichten feuchte Luftmassen in den Alpenraum.
    </WEAT_TODAY_D>
    <WEAT_TODAY_I>
    Una depressione sull'Europa Centrale convoglia masse d'aria umida in quota verso le Alpi.
    </WEAT_TODAY_I>
  </WEAT>
</WEATS>

If your text file matches the first example, (a single record), once you have added the containing element, you will then get all the field values in each record when using Magic Parser. You can see this using the Magic Parser demo tool - I pasted the above text (the single record version) into the "Option 3" form; and here is the output:

http://www.magicparser.com/demo?fileID=475DBF01762F5&record=1

Hope this helps,
Cheers,
David.