Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Utility to convert XML to value pair ? >Thread Next - Re: Utility to convert XML to value pair ? Re: Utility to convert XML to value pair ?To: NULL Date: 4/9/2008 11:14:00 PM
dingdongdingding@y... wrote:
> Is there any freeware to convert an XML to text such as
>
> Name=ABC
> Address=DEF
> Tel=123
> etc....
It depends on the structure of your XML document. For anything other
than the trivial case like
<doc>
<Name>ABC</Name>
<Address>DEF</Address>
<Tel>123</Tel>
</doc>
you'll need to provide some indication of *what* you want to extract.
However, if you just want name=value pairs regardless, the simplest tool
is to use the ESIS output of onsgmls (part of OpenSP, see
http://validator.w3.org/dist/) and two of the standard text processing
tools (grep and gawk) that you can install with Cygwin
(http://www.cygwin.com/) or GNU Utilities for Win32
(http://unxutils.sourceforge.net/)
$ onsgmls -wxml xml.dcl myfile.xml | grep -E '^(\-|\()' | grep -v
'^-\\n\\012[\ ]*$' | gawk '/^\(/ {gi=substr($0,2)} /^\-/ {print gi "=\""
substr($0,2) "\""}'
Name="ABC"
Address="DEF"
Tel="123"
///Peter
--
XML FAQ: http://xml.silmaril.ie/
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
