lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Jan 23, 2014, at 6:52 PM, Coda Highland <chighland@gmail.com> wrote:

> Text data is just another XML node. If you have
> <a1>t1<a2>t2</a2>t3</a1> then there are two text nodes: t1, t2, and
> t3. The children of a1 are, in order, t1, a2, and t3; a2 has one
> child, t2.

You might like xml2 [1]:

$ ./xml2 <<\EOF
<a1>t1<a2>t2</a2>t3</a1>
EOF

/a1=t1
/a1/a2=t2
/a1=t3

Another example, using Lua’s RSS feed:

$ curl -s http://www.lua.org/news.rss | ./xml2 | head

/rss/@version=2.0
/rss/@xmlns:atom=http://www.w3.org/2005/Atom
/rss/channel/atom:link/@href=http://www.lua.org/news.rss
/rss/channel/atom:link/@rel=self
/rss/channel/atom:link/@type=application/rss+xml
/rss/channel/title=Lua: news
/rss/channel/link=http://www.lua.org/news.html
/rss/channel/description=What's happening in the Lua world.
/rss/channel/lastBuildDate=Tue, 28 Jan 2014 22:44:57 -0200
/rss/channel/pubDate=Tue, 28 Jan 2014 22:44:57 -0200


[1] http://ofb.net/~egnor/xml2/