Erlang/OTP Forums

Author Message

<  Erlang  ~  Parse xml into a record

unclejimbob
Posted: Sat Jun 09, 2012 7:36 am Reply with quote
Joined: 09 Jun 2012 Posts: 1 Location: Australia
Hi, I'm new to Erlang and am trying to parse an XML document into a record. I have tried various methods (xmerl_scan/xpath) but get painted into a corner because I don't know enough to
know where to begin.

I've plodded through three books on the subject and spent a few hours googling the subject matter but I guess I've missed something.

There _must_ be a simple way to visit each node using some sort of pattern matching and generate a list of matches.

This is the input...

<Sports>
<Sport SportId="2" SportName="Cricket">
<League LeagueId="78" LeagueName="Test Match">
<Meeting MeetingId="357" MeetingName="Test Match"/>
</League>
<League LeagueId="79" LeagueName="One Day International">
<Meeting MeetingId="358" MeetingName="One Day International Match""/>
<Meeting MeetingId="1198" MeetingName="One Day International Series"/>
</League>
<League LeagueId="214" LeagueName="T20 World Cup">
<Meeting MeetingId="1934" MeetingName="T20 World Cup Futures"/>
</League>
</Sport>
<Sport SportId="7" SportName="Golf">
<League LeagueId="49" LeagueName="PGA Tour">
<Meeting MeetingId="185" MeetingName="St Jude Classic"/>
<Meeting MeetingId="2276" MeetingName="US Open"/>
</League>
<League LeagueId="84" LeagueName="European Tour">
<Meeting MeetingId="2721" MeetingName="Nordea Masters"/>
<Meeting MeetingId="2722" MeetingName="Nordea Masters Tournament HH"/>
<Meeting MeetingId="2723" MeetingName="Nordea Masters Top Aussie"/>
<Meeting MeetingId="2724" MeetingName="Nordea Masters Handicap"/>
<Meeting MeetingId="2725" MeetingName="Nordea Masters R1 3 Balls"/>
</League>
<League LeagueId="172" LeagueName="Ryder Cup">
<Meeting MeetingId="1176" MeetingName="Ryder Cup 2012"/>
</League>
</Sport>
<Sport SportId="11" SportName="Tennis">
<League LeagueId="98" LeagueName="ATP">
<Meeting MeetingId="1639" MeetingName="French Open Winner"/>
<Meeting MeetingId="2290" MeetingName="French Open QF Matches"/>
<Meeting MeetingId="4431" MeetingName="French Open Doubles QF Matches"/>
</League>
<League LeagueId="99" LeagueName="WTA">
<Meeting MeetingId="1885" MeetingName="French Open Winner"/>
<Meeting MeetingId="2283" MeetingName="French Open QF Matches"/>
<Meeting MeetingId="4432" MeetingName="French Open Doubles QF Matches"/>
</League>
<League LeagueId="213" LeagueName="DAVIS CUP">
<Meeting MeetingId="3537" MeetingName="Davis Cup Winner"/>
</League>
</Sport>
</Sports>

and this is what I would like as an output...

[{SportId,SportName,LeagueId,LeagueName,MeetingId,MeetingName}]

Don't necessarily need a canned answer but just a push in the right direction would be useful so I can do some further research myself.

I've used mochiweb_html:parse to search for a specific information in a particular node but in the above instance I need to extract information from multiple nodes.

thanks
ujb
View user's profile Send private message
dongdongwu
Posted: Thu Sep 20, 2012 5:43 am Reply with quote
User Joined: 19 Sep 2012 Posts: 236
His good friend Diane said: "Christian Louboutin Men Shoes was a magician, he make shoes is immediately put his female people with legs and advantage. He understands women wanted to do and can make them into beautiful Cinderella." Madonna often in its concert wearing Christian louboutin high heels , and some famous superstar like Angelina jolie, mariah Carey, beyonce Knowles, the famous Japanese singer YaYouMei Hamasaki helps Christian Louboutin Men Shoes set up its powerful position. The youngest customers will count Tom cruise's daughter sully cruz. Louboutin made for only a pair of handmade Christian Louboutin high heel Shoes! Want to be more fashion? Put on Christian Louboutin Outlet !
Candy colors of the chalaza high-heeled shoes with lolita type allure, set full finely gem blue "neon shoes" is to need to use "sexy" to describe. Each pair are worth careful appreciation of lithe and graceful fairy ludaoli, what kind of most let you move?Christian Louboutin Men Shoes that one brush red is always cannot resist the temptation, Christian Louboutin men outlet continue to use the days of high 8cm above slender heel proclaim the sexy and luxuriant. The bowknot on black pointed high-heeled shoes with sharp rivet concomitant, wild python met enchanting color printing grain, It is that pairs of high-heeled shoes lets Carrie more feminine flavour. Like Christian Louboutin for men her word.
View user's profile Send private message

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum