Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Convert txt to xml

44 views
Skip to first unread message

hssig

unread,
Feb 10, 2011, 4:38:48 AM2/10/11
to
Hi,

can someone recommend an editor which is capable of converting a
simple text file into a xml file ?


Cheers,
hssig

Martin Honnen

unread,
Feb 10, 2011, 6:22:19 AM2/10/11
to
Crosspost and followup-to comp.text.xml

hssig wrote:
> Hi,
>
> can someone recommend an editor which is capable of converting a
> simple text file into a xml file ?

I am not familiar with editors doing that but XSLT 2.0 can use the
functions unparsed-text to read in text files and the function tokenize
and the instruction analyze-string to extract data and can then output XML.
Of course you would need to post a small but representative sample of
the plain text you have and the corresponding XML you want to create.

--

Martin Honnen
http://msmvps.com/blogs/martin_honnen/

Peter Flynn

unread,
Feb 10, 2011, 3:12:56 PM2/10/11
to

Emacs with psgml-mode and xxml-mode (or nxml-mode) should be able to
help. You can use REs to detect patterns and apply markup to the
paragraph level first (while remaining non-well-formed) and then add in
sufficient containment to suit your needs.

But I would echo Martin's advice: we would need to see what you mean by
"a simple text file" :-)

///Peter

Peter Flynn

unread,
Feb 10, 2011, 3:15:01 PM2/10/11
to

I should have added that the standard text utilities are also usable for
this. awk and perl in particular would be good for matching patterns and
surrounding text with tags according to rules you write.

///Peter

0 new messages