Thread: import xml file to visual c++

  1. #1
    Registered User
    Join Date
    May 2005
    Posts
    3

    import xml file to visual c++

    hi! i'm doing a program in visual c++. But i have a problem, i need to import things of a xml file and i dunno how!

    i already tryed to find in net information but i only find help about visual c++ .net

    help me please!

    thank you

  2. #2
    VA National Guard The Brain's Avatar
    Join Date
    May 2004
    Location
    Manassas, VA USA
    Posts
    903
    i'm not sure specifically what is all inside an xml file.. but you can read in basically any text-based file into your program via use of the <fstream> library
    • "Problem Solving C++, The Object of Programming" -Walter Savitch
    • "Data Structures and Other Objects using C++" -Walter Savitch
    • "Assembly Language for Intel-Based Computers" -Kip Irvine
    • "Programming Windows, 5th edition" -Charles Petzold
    • "Visual C++ MFC Programming by Example" -John E. Swanke
    • "Network Programming Windows" -Jones/Ohlund
    • "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
    • "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel

  3. #3
    Registered User
    Join Date
    May 2005
    Posts
    3
    hi. this url already help me: http://cboard.cprogramming.com/showt...&highlight=xml

    anyway, if knowing the file would help, here he is:
    <xml version="1.0" encoding="UTF-8" standalone="no">
    <team_data>
    <team_userid>76</team_userid>
    <pm_fan>False</pm_fan>
    <team_id>89</team_id>
    <team_name>Vale de Milhaços</team_name>

    <team_country_id>1</team_country_id>
    <stadium>
    <north>2500</north>
    <south>2500</south>
    <east>2500</east>
    <west>2500</west>

    <neast>2500</neast>
    <nwest>2500</nwest>
    <seast>2500</seast>
    <swest>2500</swest>
    </stadium>
    <division>3</division>

    <series>4</series>
    <position>0</position>
    <academies>6</academies>
    <morale>6</morale>
    <games_without_winning>0</games_without_winning>
    <games_without_loosing>1</games_without_loosing>

    <wins_in_a_row>1</wins_in_a_row>
    <draws_in_a_row>0</draws_in_a_row>
    <losts_in_a_row>0</losts_in_a_row>
    <money EUR='8387225'>€8387225</money>
    <team_players>

    <player>
    <player_id>1938</player_id>

    <player_name>Ricardo Aguilar</player_name>
    <position_full>GR</position_full>
    <position>GR</position>
    <side>4</side>
    <age>29</age>
    <potencial>Má</potencial>

    <penalty_skill>Má</penalty_skill>
    <form>2</form>
    <fitness>100</fitness>
    <handling>13</handling>
    <crosses>15</crosses>
    <reflexes>9</reflexes>

    <agility>9</agility>
    <tackling>2</tackling>
    <heading>3</heading>
    <passing>7</passing>
    <positioning>6</positioning>
    <finishing>7</finishing>

    <technique>5</technique>
    <speed>19</speed>
    <strength>3</strength>
    <professionalism>5</professionalism>
    <experience>Ingénuo</experience>
    <temperament>5</temperament>

    <value EUR='276680'>€276680</value>
    <wage EUR='2334'>€2334</wage>
    <contract>1</contract>
    <last_positive_training>14</last_positive_training>
    <last_negative_training>0</last_negative_training>
    <last_positive_training_val>15</last_positive_training_val>

    <last_negative_training_val>0</last_negative_training_val>
    </player>

    <player>
    <player_id>1950</player_id>
    <player_name>Marcelo Miguéis</player_name>
    <position_full>D D</position_full>
    <position>D</position>

    <side>1</side>
    <age>32</age>
    <potencial>Má</potencial>
    <penalty_skill>Má</penalty_skill>
    <form>5</form>
    <fitness>100</fitness>

    <handling>6</handling>
    <crosses>5</crosses>
    <reflexes>6</reflexes>
    <agility>8</agility>
    <tackling>15</tackling>
    <heading>11</heading>

    <passing>15</passing>
    <positioning>10</positioning>
    <finishing>0</finishing>
    <technique>6</technique>
    <speed>13</speed>
    <strength>4</strength>

    <professionalism>3</professionalism>
    <experience>Alguma Experiência</experience>
    <temperament>0</temperament>
    <value EUR='324800'>€324800</value>
    <wage EUR='1968'>€1968</wage>
    <contract>1</contract>

    <last_positive_training>14</last_positive_training>
    <last_negative_training>0</last_negative_training>
    <last_positive_training_val>15</last_positive_training_val>
    <last_negative_training_val>0</last_negative_training_val>
    </player>

    <player>
    <player_id>94351</player_id>

    <player_name>António Varela</player_name>
    <position_full>M C</position_full>
    <position>M</position>
    <side>0</side>
    <age>32</age>
    <potencial>Má</potencial>

    <penalty_skill>Má</penalty_skill>
    <form>3</form>
    <fitness>100</fitness>
    <handling>2</handling>
    <crosses>7</crosses>
    <reflexes>5</reflexes>

    <agility>7</agility>
    <tackling>14</tackling>
    <heading>5</heading>
    <passing>16</passing>
    <positioning>11</positioning>
    <finishing>2</finishing>

    <technique>14</technique>
    <speed>3</speed>
    <strength>5</strength>
    <professionalism>3</professionalism>
    <experience>Alguma Experiência</experience>
    <temperament>3</temperament>

    <value EUR='278933'>€278933</value>
    <wage EUR='1926'>€1926</wage>
    <contract>1</contract>
    <last_positive_training>14</last_positive_training>
    <last_negative_training>0</last_negative_training>
    <last_positive_training_val>15</last_positive_training_val>

    <last_negative_training_val>0</last_negative_training_val>
    </player>

    <player>
    <player_id>100651</player_id>
    <player_name>Antonio Ortiz</player_name>
    <position_full>A DE</position_full>
    <position>A</position>

    <side>3</side>
    <age>34</age>
    <potencial>Má</potencial>
    <penalty_skill>Má</penalty_skill>
    <form>5</form>
    <fitness>100</fitness>

    <handling>6</handling>
    <crosses>5</crosses>
    <reflexes>8</reflexes>
    <agility>7</agility>
    <tackling>5</tackling>
    <heading>15</heading>

    <passing>4</passing>
    <positioning>10</positioning>
    <finishing>15</finishing>
    <technique>14</technique>
    <speed>0</speed>
    <strength>5</strength>

    <professionalism>4</professionalism>
    <experience>Alguma Experiência</experience>
    <temperament>2</temperament>
    <value EUR='317220'>€317220</value>
    <wage EUR='1802'>€1802</wage>
    <contract>1</contract>

    <last_positive_training>14</last_positive_training>
    <last_negative_training>0</last_negative_training>
    <last_positive_training_val>15</last_positive_training_val>
    <last_negative_training_val>0</last_negative_training_val>
    </player>

    <player>
    <player_id>53386</player_id>

    <player_name>Adriano Filho</player_name>
    <position_full>A E</position_full>
    <position>A</position>
    <side>2</side>
    <age>25</age>
    <potencial>Fraca</potencial>

    <penalty_skill>Fraca</penalty_skill>
    <form>2</form>
    <fitness>100</fitness>
    <handling>1</handling>
    <crosses>2</crosses>
    <reflexes>5</reflexes>

    <agility>0</agility>
    <tackling>3</tackling>
    <heading>11</heading>
    <passing>5</passing>
    <positioning>11</positioning>
    <finishing>14</finishing>

    <technique>16</technique>
    <speed>6</speed>
    <strength>7</strength>
    <professionalism>4</professionalism>
    <experience>Bastante Ingénuo</experience>
    <temperament>0</temperament>

    <value EUR='302269'>€302269</value>
    <wage EUR='1784'>€1784</wage>
    <contract>5</contract>
    <last_positive_training>14</last_positive_training>
    <last_negative_training>0</last_negative_training>
    <last_positive_training_val>15</last_positive_training_val>

    <last_negative_training_val>0</last_negative_training_val>
    </player>

    <player>
    <player_id>80234</player_id>
    <player_name>Sérgio Dias</player_name>
    <position_full>D D</position_full>
    <position>D</position>

    <side>1</side>
    <age>31</age>
    <potencial>Má</potencial>
    <penalty_skill>Má</penalty_skill>
    <form>2</form>
    <fitness>100</fitness>

    <handling>7</handling>
    <crosses>4</crosses>
    <reflexes>3</reflexes>
    <agility>4</agility>
    <tackling>11</tackling>
    <heading>17</heading>

    <passing>12</passing>
    <positioning>16</positioning>
    <finishing>4</finishing>
    <technique>0</technique>
    <speed>11</speed>
    <strength>8</strength>

    <professionalism>2</professionalism>
    <experience>Alguma Experiência</experience>
    <temperament>4</temperament>
    <value EUR='317229'>€317229</value>
    <wage EUR='2089'>€2089</wage>
    <contract>2</contract>

    <last_positive_training>14</last_positive_training>
    <last_negative_training>0</last_negative_training>
    <last_positive_training_val>15</last_positive_training_val>
    <last_negative_training_val>0</last_negative_training_val>
    </player>

    <player>
    <player_id>134766</player_id>

    <player_name>Roberto Baptista</player_name>
    <position_full>D E</position_full>
    <position>D</position>
    <side>2</side>
    <age>26</age>
    <potencial>Má</potencial>

    <penalty_skill>Má</penalty_skill>
    <form>5</form>
    <fitness>96</fitness>
    <handling>1</handling>
    <crosses>8</crosses>
    <reflexes>0</reflexes>

    <agility>5</agility>
    <tackling>12</tackling>
    <heading>18</heading>
    <passing>10</passing>
    <positioning>13</positioning>
    <finishing>12</finishing>

    <technique>2</technique>
    <speed>3</speed>
    <strength>11</strength>
    <professionalism>3</professionalism>
    <experience>Ingénuo</experience>
    <temperament>2</temperament>

    <value EUR='410919'>€410919</value>
    <wage EUR='2185'>€2185</wage>
    <contract>5</contract>
    <last_positive_training>0</last_positive_training>
    <last_negative_training>0</last_negative_training>
    <last_positive_training_val>0</last_positive_training_val>

    <last_negative_training_val>0</last_negative_training_val>
    </player>

    <player>
    <player_id>155845</player_id>
    <player_name>Rafael Centeio</player_name>
    <position_full>D E</position_full>
    <position>D</position>

    <side>2</side>
    <age>26</age>
    <potencial>Má</potencial>
    <penalty_skill>Má</penalty_skill>
    <form>3</form>
    <fitness>95</fitness>

    <handling>1</handling>
    <crosses>8</crosses>
    <reflexes>0</reflexes>
    <agility>5</agility>
    <tackling>12</tackling>
    <heading>18</heading>

    <passing>10</passing>
    <positioning>13</positioning>
    <finishing>12</finishing>
    <technique>2</technique>
    <speed>3</speed>
    <strength>11</strength>

    <professionalism>3</professionalism>
    <experience>Ingénuo</experience>
    <temperament>2</temperament>
    <value EUR='332662'>€332662</value>
    <wage EUR='2150'>€2150</wage>
    <contract>5</contract>

    <last_positive_training>0</last_positive_training>
    <last_negative_training>0</last_negative_training>
    <last_positive_training_val>0</last_positive_training_val>
    <last_negative_training_val>0</last_negative_training_val>
    </player>

    <player>
    <player_id>194905</player_id>

    <player_name>Oscar Contreras</player_name>
    <position_full>D E</position_full>
    <position>D</position>
    <side>2</side>
    <age>26</age>
    <potencial>Fraca</potencial>

    <penalty_skill>Fraca</penalty_skill>
    <form>1</form>
    <fitness>94</fitness>
    <handling>9</handling>
    <crosses>9</crosses>
    <reflexes>8</reflexes>

    <agility>3</agility>
    <tackling>16</tackling>
    <heading>15</heading>
    <passing>10</passing>
    <positioning>5</positioning>
    <finishing>17</finishing>

    <technique>7</technique>
    <speed>14</speed>
    <strength>0</strength>
    <professionalism>3</professionalism>
    <experience>Ingénuo</experience>
    <temperament>2</temperament>

    <value EUR='260678'>€260678</value>
    <wage EUR='2115'>€2115</wage>
    <contract>5</contract>
    <last_positive_training>0</last_positive_training>
    <last_negative_training>0</last_negative_training>
    <last_positive_training_val>0</last_positive_training_val>

    <last_negative_training_val>0</last_negative_training_val>
    </player>

    <player>
    <player_id>565776</player_id>
    <player_name>Soare Danciu</player_name>
    <position_full>M D</position_full>
    <position>M</position>

    <side>1</side>
    <age>20</age>
    <potencial>Má</potencial>
    <penalty_skill>Má</penalty_skill>
    <form>3</form>
    <fitness>98</fitness>

    <handling>5</handling>
    <crosses>1</crosses>
    <reflexes>6</reflexes>
    <agility>1</agility>
    <tackling>18</tackling>
    <heading>1</heading>

    <passing>11</passing>
    <positioning>12</positioning>
    <finishing>7</finishing>
    <technique>17</technique>
    <speed>1</speed>
    <strength>6</strength>

    <professionalism>5</professionalism>
    <experience>Bastante Ingénuo</experience>
    <temperament>4</temperament>
    <value EUR='294722'>€294722</value>
    <wage EUR='1907'>€1907</wage>
    <contract>5</contract>

    <last_positive_training>0</last_positive_training>
    <last_negative_training>0</last_negative_training>
    <last_positive_training_val>0</last_positive_training_val>
    <last_negative_training_val>0</last_negative_training_val>
    </player>

    </team_players>
    </team_data>

    </xml>

  4. #4
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    Don't use <fstream> (explicitly). This will cause you great pain as you will essentially have to write an XML parser from scratch.

    I've not done too much work with XML parsers, but I know there are a number of them out there for C/C++:
    Xerces C++ Parser: http://xml.apache.org/xerces-c/
    libxml: http://xmlsoft.org/
    Expat: http://expat.sourceforge.net/

    And, a more comprehensive list here:

    Perhaps someone here has experience with some of these, but if not, choose one, go through the example code and API documentation, and you should be able to figure out how to use it.

    Cheers
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  5. #5
    Registered User
    Join Date
    May 2005
    Posts
    3
    thank you. i will try to find out how to use it

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Avoiding Global variables
    By csonx_p in forum Windows Programming
    Replies: 32
    Last Post: 05-19-2008, 12:17 AM
  2. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 05:02 AM
  3. help with text input
    By Alphawaves in forum C Programming
    Replies: 8
    Last Post: 04-08-2007, 04:54 PM
  4. pointer to array of objects of struct
    By undisputed007 in forum C++ Programming
    Replies: 12
    Last Post: 03-02-2004, 04:49 AM
  5. Linking error
    By DockyD in forum C++ Programming
    Replies: 10
    Last Post: 01-20-2003, 05:27 AM