Getting data out of an XML File using TinyXml 2



So, basically, I have an XML file, that needs to be parsed, all I need are the home name attribute and the away name attribute. I tried following the tutorials, but I just seem unable to understand it. So I'd really appreciate it if I could get code all the way from the top, and comments to explain the steps.


Here is the XML File:-



<matches>
<match id="293cc5b0-084a-4570-9c8b-3aecbfcdac72" status="closed" scratched="false" season_id="72025ee3-f99a-4c71-8f39-a658d7d95697" scheduled="2014-12-05T17:00:00Z">
<category id="d1a50060-2ceb-45b6-ae08-b3a1ca38da86" name="Ukraine" country_code="UKR" country="Ukraine"/>
<tournament_group id="1a5bfc9a-57ed-49a6-9a9f-ac1e9f3fcc09" name="Premier League" season_start="2014-07-24T22:00:00Z" season_end="2015-06-01T21:59:00Z" season="2014"/>
<tournament id="417d7be0-3b5b-4573-9b72-e8c037093f6a" name="Premier League" season_id="72025ee3-f99a-4c71-8f39-a658d7d95697" season_start="2014-07-24T22:00:00Z" season_end="2015-06-01T21:59:00Z" season="2014"/>
<home id="fb78bcfc-5df9-4d3f-9097-944b1fa305aa" name="FC Dynamo Kiev" alias="DYK" country_code="UKR" country="Ukraine" type="team"/>
<away id="e0635d1d-16cb-4dd2-849e-86656a71e063" name="FC Metalurg Donetsk" alias="DON" country_code="UKR" country="Ukraine" type="team"/>
<venue id="22213968-9466-4d19-8b27-58a32888b4b3" name="Olimpiysky National Sports Complex" country_code="UKR" city="Kiev" capacity="70050" country="Ukraine" coordinates="50.433439,30.522114"/>
<round week="49" number="10" type="table"/>
<!-- 5697458/3305/3311 -->
</match>
<match id="e2bebad3-87cf-4fc8-a9a6-70202cdbb6e4" status="closed" scratched="false" season_id="72025ee3-f99a-4c71-8f39-a658d7d95697" scheduled="2014-12-05T17:00:00Z">
<category id="d1a50060-2ceb-45b6-ae08-b3a1ca38da86" name="Ukraine" country_code="UKR" country="Ukraine"/>
<tournament_group id="1a5bfc9a-57ed-49a6-9a9f-ac1e9f3fcc09" name="Premier League" season_start="2014-07-24T22:00:00Z" season_end="2015-06-01T21:59:00Z" season="2014"/>
<tournament id="417d7be0-3b5b-4573-9b72-e8c037093f6a" name="Premier League" season_id="72025ee3-f99a-4c71-8f39-a658d7d95697" season_start="2014-07-24T22:00:00Z" season_end="2015-06-01T21:59:00Z" season="2014"/>
<home id="4de003dc-8627-4ab3-adff-0b05f700e179" name="FC Shakhtar Donetsk" alias="SHA" country_code="UKR" country="Ukraine" type="team"/>
<away id="20565616-f0c6-4560-a28f-bedeea31e476" name="Goverla-Uzhgorod" alias="UZG" country_code="UKR" country="Ukraine" type="team"/>
<venue id="a78a10ac-1b9f-41e4-8706-b03c4b6ffbef" name="Arena Lviv" country_code="UKR" city="Lviv" capacity="34915" country="Ukraine" coordinates="49.775278,24.027778"/>
<round week="49" number="10" type="table"/>
<!-- 5697460/3313/7635 -->
</match>
<match id="835a1f3d-b0f4-456f-9a35-98a3a3831af8" status="closed" scratched="false" season_id="a5e7a535-6179-4025-80b2-5eb119e8eb8f" scheduled="2014-12-05T17:30:00Z">
<category id="44a9cc8d-d1a6-4834-8340-d0ba3ff6a825" name="Denmark" country_code="DNK" country="Denmark"/>
<tournament_group id="c563045a-1b31-4208-a1c4-97634a62e036" name="Superligaen" season_start="2014-07-17T22:00:00Z" season_end="2015-06-07T21:59:00Z" season="2014"/>
<tournament id="e1865345-e040-4131-adb8-df8b92ff9df3" name="Superligaen" season_id="a5e7a535-6179-4025-80b2-5eb119e8eb8f" season_start="2014-07-17T22:00:00Z" season_end="2015-06-07T21:59:00Z" season="2014"/>
<home id="d445e3b3-e07b-4d22-a104-1ee453ea9105" name="Randers FC" alias="RAN" country_code="DNK" country="Denmark" type="team"/>
<away id="819013ac-88a8-42e9-ab74-f46613ddee6c" name="SonderjyskE" alias="SON" country_code="DNK" country="Denmark" type="team"/>
<venue id="72feb83d-a097-42a8-964e-dd82f73915c4" name="AutoC Park" country_code="DNK" city="Randers" capacity="9000" country="Denmark" coordinates="56.465955,10.010346"/>
<round week="49" number="17" type="table"/>
<!-- 5532262/1301/1295 -->
</match>
</matches>


Thanks in advance! P.S. I have a very basic understanding pf C++, I'm still in school. I understand arrays, pointers and linked lists and its derived data structures, but I have no clue about vectors and the like.


No comments:

Post a Comment