r - XML Parse data within node -


i trying parse xml. have taken xml webpage using xmltreeparse split cards/meeting/race nodes. if @ 1st meeting node, how extract:

meeting name,

id,

diffusion_course_name

currently whenever try extract anything, end 'race' children. want meeting details?

many thanks!

> getnodeset(top,"//cards/meeting[1]") [[1]] <meeting name="bath" id="5" diffusion_course_name="bath">   <race id="680058" perform_race_id="" perform_race_id_atr="224436" details_available="1" race_status_code="o">     <time>2:10</time>     <date>2017-07-26</date>     <ampm>pm</ampm>     <title>british stallion studs ebf novice stakes (plus 10 race)</title>     <type>f</type>     <distance>5f10y</distance>     <group/>     <tipsallowed>1</tipsallowed>     <predictorallowed>1</predictorallowed>     <bettinglink>1</bettinglink>     <declaredrunners>5</declaredrunners>     <livecommentary>1</livecommentary>     <livetab>1</livetab>     <racedescription>class 4 novice</racedescription>     <tvtext>atr </tvtext>   </race>   <race id="680061" perform_race_id="" perform_race_id_atr="224438" details_available="1" race_status_code="o">     <time>2:40</time>     <date>2017-07-26</date>     <ampm>pm</ampm>     <title>rainbow casino bristol handicap (bath summer sprint series qualifier)</title>     <type>f</type>     <distance>5f160y</distance>     <group>handicap</group>     <tipsallowed>1</tipsallowed>     <predictorallowed>1</predictorallowed>     <bettinglink>1</bettinglink>     <declaredrunners>13</declaredrunners>     <livecommentary>1</livecommentary>     <livetab>1</livetab>     <racedescription>class 5 handicap</racedescription>     <tvtext>atr </tvtext>   </race>   <race id="680056" perform_race_id="" perform_race_id_atr="224439" details_available="1" race_status_code="o">     <time>3:10</time>     <date>2017-07-26</date>     <ampm>pm</ampm>     <title>rainbow casino birmingham handicap</title>     <type>f</type>     <distance>5f160y</distance>     <group>handicap</group>     <tipsallowed>1</tipsallowed>     <predictorallowed>1</predictorallowed>     <bettinglink>1</bettinglink>     <declaredrunners>5</declaredrunners>     <livecommentary>1</livecommentary>     <livetab>1</livetab>     <racedescription>class 4 handicap</racedescription>     <tvtext>atr </tvtext>   </race>   <race id="680055" perform_race_id="" perform_race_id_atr="224442" details_available="1" race_status_code="o">     <time>3:40</time>     <date>2017-07-26</date>     <ampm>pm</ampm>     <title>rainbow casinos cardiff fillies' handicap</title>     <type>f</type>     <distance>1m3f137y</distance>     <group>handicap</group>     <tipsallowed>1</tipsallowed>     <predictorallowed>1</predictorallowed>     <bettinglink>1</bettinglink>     <declaredrunners>6</declaredrunners>     <livecommentary>1</livecommentary>     <livetab>1</livetab>     <racedescription>class 3 handicap</racedescription>     <tvtext>atr </tvtext>   </race>   <race id="680059" perform_race_id="" perform_race_id_atr="224443" details_available="1" race_status_code="o">     <time>4:10</time>     <date>2017-07-26</date>     <ampm>pm</ampm>     <title>rainbow casino aberdeen handicap (bath summer stayers' series qualifier)</title>     <type>f</type>     <distance>1m6f</distance>     <group>handicap</group>     <tipsallowed>1</tipsallowed>     <predictorallowed>1</predictorallowed>     <bettinglink>1</bettinglink>     <declaredrunners>8</declaredrunners>     <livecommentary>1</livecommentary>     <livetab>1</livetab>     <racedescription>class 5 handicap</racedescription>     <tvtext>atr </tvtext>   </race>   <race id="680060" perform_race_id="" perform_race_id_atr="224447" details_available="1" race_status_code="o">     <time>4:40</time>     <date>2017-07-26</date>     <ampm>pm</ampm>     <title>rainbow bristol poker handicap</title>     <type>f</type>     <distance>1m2f37y</distance>     <group>handicap</group>     <tipsallowed>1</tipsallowed>     <predictorallowed>1</predictorallowed>     <bettinglink>1</bettinglink>     <declaredrunners>8</declaredrunners>     <livecommentary>1</livecommentary>     <livetab>1</livetab>     <racedescription>class 5 handicap</racedescription>     <tvtext>atr </tvtext>   </race>   <race id="680057" perform_race_id="" perform_race_id_atr="224446" details_available="1" race_status_code="o">     <time>5:10</time>     <date>2017-07-26</date>     <ampm>pm</ampm>     <title>rainbow casinos open 24/7 handicap</title>     <type>f</type>     <distance>1m</distance>     <group>handicap</group>     <tipsallowed>1</tipsallowed>     <predictorallowed>1</predictorallowed>     <bettinglink>1</bettinglink>     <declaredrunners>8</declaredrunners>     <livecommentary>1</livecommentary>     <livetab>1</livetab>     <racedescription>class 4 handicap</racedescription>     <tvtext>atr </tvtext>   </race> </meeting>   attr(,"class") [1] "xmlnodeset" 

you can try xmls2js.it converts xml javascript. or can use xml2json module of nodejs. https://www.npmjs.com/package/xml2json


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -