Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: create an xml file from column file

by hdb (Parson)
on Jul 24, 2013 at 10:55 UTC ( #1046071=note: print w/ replies, xml ) Need Help??


in reply to create an xml file from column file

The "NP" in your desired output is taken from which line of your input?




Comment on Re: create an xml file from column file
Download Code
Re^2: create an xml file from column file
by lakssreedhar (Acolyte) on Jul 24, 2013 at 11:14 UTC

    the full output i want is as shown

    <text> how are you> </text> <annotation><type> NP</type><text>how></text></annotation><annotation><type>NP</type><text>are</text></annotation><annotation><type>NP</type><text>you</text></annotation>

    so the type should contain the 2nd column of corresponding text in the tab seperated input file

      Ah! Then this is how I would do it:

      1. Loop over the lines of your input.
      2. Extract all word characters from the beginning of the line for the text field.
      3. Extract all word characters at the end of the line for the type field.
      4. Independently build the initial <text>...</text> and the <annotation>...</annotation> parts by adding them to two strings.
      5. After the loop print the two strings into an xml file.



Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1046071]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (14)
As of 2014-07-23 12:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (140 votes), past polls