C
CuriousCoder15
Guest
Hi,
I'm reading through an xml file that is rather large, my aim is to take certain node values and add them to my database. Here is a sample xml:
<EVENT>
<EVENT_DETAIL>
<EVENT_HEADING>
<EVENT_HEADER_1>
<VENUE>Main Track</VENUE>
<CIRCUIT>2</CIRCUIT>
<EVENT_TIME>13:05</EVENT_TIME>
<PARTY>12</PARTY>
</EVENT_HEADER_1>
<EVENT_HEADER_2>
<EVENT_TITLE>BEST OF THE BEST</EVENT_TITLE>
<DISTANCE>100m</DISTANCE>
</EVENT_HEADER_2>
</EVENT_HEADING>
<PLAYER>
<PLAYER_HEADER_1>
<NO>1</NO>
<NAME>D.Jones</NAME>
<WEIGHT>70k</WEIGHT>
</PLAYER_HEADER_1>
<PLAYER_HEADER_2>
<COACH>A Wright</COACH>
<COACH_2>K Naidoo</COACH_2>
<COACH_YEAR>2017</COACH_YEAR>
<OWNER>Mr Roy Johnson</OWNER>
<ASSISTANT>S Davies</ASSISTANT>
<COMMENT>Running late</COMMENT>
</PLAYER_HEADER_2>
</PLAYER>
<PLAYER>
<PLAYER>
<PLAYER>
<PLAYER>
<PLAYER>
<PLAYER>
</EVENT_DETAIL>
</EVENT>
There are multiple <EVENT> in the xml file, I want to get <VENUE> <CIRCUIT> <EVENT_TIME> <EVENT_TITLE> <DISTANCE> <NO> <NAME> <WEIGHT> <COACH> <OWNER> <ASSISTANT> There are also multiple <PLAYER> within an event.
I used the following for each node <g class="gr_ gr_223 gr-alert gr_tiny gr_spell gr_inline_cards gr_run_anim ContextualSpelling multiReplace" data-gr-id="223" id="223">i</g> wanted:
var venue= doc.Root.Descendants("VENUE").Select(c => c.Value);
Which gathered all the values and did this for each node that I wanted but I'm not sure this is the right approach. I Imagined if I captured all the nodes that I wanted from the first instance of <EVENT> and added them to a list the iterate through and upload to the DB then on the next instance of <EVENT> instantiate a new list and repeat.
Not sure how to go about this, any examples or pointers would be really appreciated.
CuriousCoder
Continue reading...
I'm reading through an xml file that is rather large, my aim is to take certain node values and add them to my database. Here is a sample xml:
<EVENT>
<EVENT_DETAIL>
<EVENT_HEADING>
<EVENT_HEADER_1>
<VENUE>Main Track</VENUE>
<CIRCUIT>2</CIRCUIT>
<EVENT_TIME>13:05</EVENT_TIME>
<PARTY>12</PARTY>
</EVENT_HEADER_1>
<EVENT_HEADER_2>
<EVENT_TITLE>BEST OF THE BEST</EVENT_TITLE>
<DISTANCE>100m</DISTANCE>
</EVENT_HEADER_2>
</EVENT_HEADING>
<PLAYER>
<PLAYER_HEADER_1>
<NO>1</NO>
<NAME>D.Jones</NAME>
<WEIGHT>70k</WEIGHT>
</PLAYER_HEADER_1>
<PLAYER_HEADER_2>
<COACH>A Wright</COACH>
<COACH_2>K Naidoo</COACH_2>
<COACH_YEAR>2017</COACH_YEAR>
<OWNER>Mr Roy Johnson</OWNER>
<ASSISTANT>S Davies</ASSISTANT>
<COMMENT>Running late</COMMENT>
</PLAYER_HEADER_2>
</PLAYER>
<PLAYER>
<PLAYER>
<PLAYER>
<PLAYER>
<PLAYER>
<PLAYER>
</EVENT_DETAIL>
</EVENT>
There are multiple <EVENT> in the xml file, I want to get <VENUE> <CIRCUIT> <EVENT_TIME> <EVENT_TITLE> <DISTANCE> <NO> <NAME> <WEIGHT> <COACH> <OWNER> <ASSISTANT> There are also multiple <PLAYER> within an event.
I used the following for each node <g class="gr_ gr_223 gr-alert gr_tiny gr_spell gr_inline_cards gr_run_anim ContextualSpelling multiReplace" data-gr-id="223" id="223">i</g> wanted:
var venue= doc.Root.Descendants("VENUE").Select(c => c.Value);
Which gathered all the values and did this for each node that I wanted but I'm not sure this is the right approach. I Imagined if I captured all the nodes that I wanted from the first instance of <EVENT> and added them to a list the iterate through and upload to the DB then on the next instance of <EVENT> instantiate a new list and repeat.
Not sure how to go about this, any examples or pointers would be really appreciated.
CuriousCoder
Continue reading...