read XML file in c++ need urgent help

This is a discussion on read XML file in c++ need urgent help within the C++ Programming forums, part of the General Programming Boards category; Hi Code: I'm trying to read an XML file (below) using C++. Please help! <?xml version="1.0" encoding="utf-8" ?> <nodes> <node ...

  1. #1
    Registered User
    Join Date
    Nov 2008
    Posts
    133

    Thumbs up read XML file in c++ need urgent help

    Hi
    Code:
    I'm trying to read an XML file (below) using C++. Please help!
    
    
    <?xml version="1.0" encoding="utf-8" ?> 
    <nodes>
    <node id="n1" x="25" y="25" connection="n2,n3" /> 
    <node id="n2" x="110" y="110" connection="n1,n3,n4" /> 
    <node id="n3" x="50" y="180" connection="n1,n2,n5,n6" /> 
    <node id="n4" x="225" y="90" connection="n2,n5,n6" /> 
    <node id="n5" x="190" y="160" connection="n3,n4" /> 
    <node id="n6" x="230" y="170" connection="n3,n4" /> 
    </nodes>

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    20,980
    Search the Web for "C++ XML parser".
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Nov 2008
    Posts
    133
    Quote Originally Posted by laserlight View Post
    Search the Web for "C++ XML parser".
    there are so many c++ xml parser available. but what is the logic to read data from xml file using c++ and display on the screen??

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    20,980
    Quote Originally Posted by leo2008
    there are so many c++ xml parser available. but what is the logic to read data from xml file using c++ and display on the screen??
    Pick a few parsers, read their documentation, and use one that meets your needs.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    3,831
    but what is the logic to read data from xml file using c++ and display on the screen??
    Do you really want to know how parsers work? I ask because it can mean years of study to understand parser theory.

    Or do you just want to get the job of parsing done? I ask because using an existing library will be fairly easy. As laserlight says, just pick one; flip a coin if you must.

    Soma

  6. #6
    Registered User
    Join Date
    Oct 2006
    Posts
    2,149
    tinyxml and tinyxpath will probably solve all your problems.

  7. #7
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,641

  8. #8
    Registered User
    Join Date
    May 2012
    Posts
    3
    tinyxml seems to be the most popular one, although I have also come across tinyxml++ but have not used it yet, or liquid xml c++ tool will happily do the job as well.

  9. #9
    Registered User
    Join Date
    May 2009
    Posts
    2,372
    Quote Originally Posted by joethomas View Post
    tinyxml seems to be the most popular one, although I have also come across tinyxml++ but have not used it yet, or liquid xml c++ tool will happily do the job as well.
    Looks like the site has two versions now.
    TinyXML-2

    Tim S.
    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the Universe is winning." Rick Cook

  10. #10
    Internet Superhero
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    934
    If all you want to do is read XML, boost::property tree is the easiest way to go.

    It's dead simple, it's header only, so no compiling and linking libraries, and it has xpath-esque syntax for easy access to the XML data.
    How I need a drink, alcoholic in nature, after the heavy lectures involving quantum mechanics.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How can I know the actual bytes read in a file read
    By pliang in forum C++ Programming
    Replies: 1
    Last Post: 06-08-2005, 04:23 PM
  2. Help with file reading...[Urgent]
    By alvifarooq in forum C++ Programming
    Replies: 19
    Last Post: 09-18-2004, 06:19 PM
  3. Problem loading file...URGENT
    By khpuce in forum C Programming
    Replies: 4
    Last Post: 05-19-2003, 08:14 AM
  4. how to delete a file?URGENT!!!!!
    By subme in forum C Programming
    Replies: 1
    Last Post: 05-12-2003, 09:32 AM
  5. Replies: 1
    Last Post: 12-01-2002, 12:24 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21