Thread: Win32 API & XML question

  1. #1
    Registered User
    Join Date
    Sep 2004
    Posts
    20

    Win32 API & XML question

    I`m using Visual C++ .NET but writting under Win32 API, and I wanna read from XML file. Is there any header or something that I can read data from XML file. THNX and sorry for so many posts. C ya
    Butterfly sweep can make torando in another side of world

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    There's an activeX control with the progid of "Microsoft.XMLDOM"

    You'd need to be confortable with COM and acitveX though

  3. #3
    Banal internet user
    Join Date
    Aug 2002
    Posts
    1,380
    I don't think there's a standard win32 API for XML reading.

    Too bad you're not using the .NET stuff, it's very easy with that.

  4. #4
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    google: c++ xml parser

    gg

  5. #5
    Registered User
    Join Date
    Dec 2003
    Posts
    50
    You could check out Microsoft's XML Parser and its SDK.
    They are available as downloads from Microsoft's site.

    Or, if you are processing simple XML files, you might want to check out TinyXML.

  6. #6
    Registered User
    Join Date
    Sep 2004
    Posts
    20
    Hi there, so... If I will use TinyXML in my program, I must have .NET Framework version 1.1. on my computer?
    Butterfly sweep can make torando in another side of world

  7. #7
    Registered User
    Join Date
    Dec 2003
    Posts
    50
    Hi,

    TinyXML does not need the .NET framework.

    From its documentation page:
    In brief, TinyXml parses an XML document, and builds from that a Document Object Model (DOM) that can be read, modified, and saved.

    XML stands for "eXtensible Markup Language." It allows you to create your own document markups. Where HTML does a very good job of marking documents for browsers, XML allows you to define any kind of document markup, for example a document that describes a "to do" list for an organizer application. XML is a very structured and convenient format. All those random file formats created to store application data can all be replaced with XML. One parser for everything.

    There are different ways to access and interact with XML data. TinyXml uses a Document Object Model (DOM), meaning the XML data is parsed into a tree objects that can be browsed and manipulated, and then written back to disk. You can also construct an XML document from scratch with C++ objects and write this to disk (or another output stream.)

    TinyXml is designed to be easy and fast. It is two headers and four cpp files. Simply add these to your project and off you go. There is an example to get you started. It is released under the ZLib license, so you can use it in open source or commercial code.

    It attempts to be a flexible parser, but with truly correct and compliant XML output (with the exception of the character set, below.) TinyXml should compile on any reasonably C++ system. It does not rely on exceptions or RTTI. It can be compiled with or without STL support.
    The URL is: http://www.grinninglizard.com/tinyxml/

    Best Regards,
    Yeoh
    --

  8. #8
    Registered User
    Join Date
    Sep 2004
    Posts
    20
    Hi I started to use TinyXML parser, lear to read to .xml doc but I can`t read from it :/ for eg. I wanna read the value <x>50</x> how should I read that value that can assign 50 to integer? THNX C ya.
    Butterfly sweep can make torando in another side of world

  9. #9
    Registered User
    Join Date
    Dec 2003
    Posts
    50
    Hi,

    TinyXML comes with an example program: xmltest.cpp.

    You can get the value of a node like this: node->Value();

    From xmltest example:
    Code:
    	node = doc.RootElement();
    	XmlTest( "Root element exists.", true, ( node != 0 && node->ToElement() ) );
    	XmlTest ( "Root element value is 'ToDo'.", "ToDo",  node->Value());
    
    	node = node->FirstChild();
    	XmlTest( "First child exists & is a comment.", true, ( node != 0 && node->ToComment() ) );
    	node = node->NextSibling();
    	XmlTest( "Sibling element exists & is an element.", true, ( node != 0 && node->ToElement() ) );
    	XmlTest ( "Value is 'Item'.", "Item", node->Value() );
    
    	node = node->FirstChild();
    	XmlTest ( "First child exists.", true, ( node != 0 && node->ToText() ) );
    	XmlTest ( "Value is 'Go to the'.", "Go to the", node->Value() );
    Best Regards,
    Yeoh
    --

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. WIN32 API Controls used with Resource
    By parad0x13 in forum C++ Programming
    Replies: 0
    Last Post: 07-19-2008, 02:05 PM
  2. Win32 API help
    By 52Cent in forum Windows Programming
    Replies: 8
    Last Post: 01-23-2008, 10:24 AM
  3. Textbox in Win32 API ???
    By actionbasti in forum Windows Programming
    Replies: 1
    Last Post: 11-07-2003, 02:29 AM
  4. Win32 API Questions
    By CPP-Null in forum C++ Programming
    Replies: 1
    Last Post: 05-25-2003, 04:26 PM
  5. Beginner on Win32 apps, lame question.
    By Templario in forum C Programming
    Replies: 3
    Last Post: 11-06-2002, 08:39 PM