extract xml from txt doc using sed/awk

October 25, 2010 at 06:33:45
Specs: Windows XP
Hello,


I would like to create a .ksh script which cuts certain XML data from a document. I have tried to use SED and AWK and piping but its been some time since i have operated on Linux and my memory is patchy.

I would like the script to open a file that user wants.. cut certain information from that document and write it to another file.

[code]
sed 's/^[ \t]*//' Statement.xml | awk '/objectName|fieldValue|fieldName/' | less
[/code]


i have done the above which works.. it alligns all the information to the left making it easier on the eye intially then cuts all the information matching objectName etc.. however i now need the script to ask the user what file they wish to open, and the XML that was extracted needs to be put into another file.


Thanks


See More: extract xml from txt doc using sed/awk

Report •

#1
October 25, 2010 at 08:05:02
[code]

sed 's/^[ \t]*//' trace.txt | awk '/objectName|fieldValue|fieldName|fieldID|retirementDate|policyId/' > output

[/code]

I have come up with this, it does work however it ONLY EXTRACTS the information that i have specified... "objectName|fieldValue|fieldName|fieldID|retirementDate|policyId "

Not all documents will contain objectName,fieldID, so now i need to look at how to copy the xml from a certain point in the document to another point. Does anyone know how to do this?

In the txt file ' trace.txt' everything after the words 'Sending XML' needs to be put in the output file.


Report •

#2
October 26, 2010 at 06:33:35
Is there any one out there?

Report •
Related Solutions


Ask Question