Results 1 to 6 of 6

Thread: How to export data to XML from the visual C++

  1. #1
    Join Date
    Jun 2011
    Posts
    61

    How to export data to XML from the visual C++

    Hi I have developed application using the visual C++ and I am in great trouble right now, I mean to say that I require some reference to export few data in XML format using VC++, but don’t know how to do that exactly, but I am aware about some libraries and all that things, through which we can do this but don’t know exactly how can we do that, I prefer MFC compatible classes, and need some proper explanation. Thanks.

  2. #2
    Join Date
    Apr 2009
    Posts
    569

    Re: How to export data to XML from the visual C++

    You need to have some XML parser for these to export the data from the VC++ to the XML, but and you have to write different application to export those data to the XML format. And as the extent to I know you can use Dom Parser for this, off course first of all you have to download it from the internet, and then make use in the programming. And if suppose you still have some doubts you can simply refer to the MSDN library.

  3. #3
    Join Date
    May 2009
    Posts
    539

    Re: How to export data to XML from the visual C++

    you can do this with the coding only, and for that you need to import some of the files and the libraries in your coding, see you can try this.

    Code:
    #import <msxml.dll> named_guids
    using namespace MSXML;
    And as the above user has mentioned, you have to use the DOM parser which is very good interface load the XML files.

  4. #4
    Join Date
    Apr 2009
    Posts
    488

    Re: How to export data to XML from the visual C++

    See first of all you need to create the XML file and then you have to import it in the visual C++ program using the name that you have mentioned. See I would like to give you one best example.

    XML file

    Code:
    <?xml version="1.0"?>
    <cars>
      <company name="AUDI">
        <producer name="ABC">
          <model>X6 Convertible</model>
          <price currency="usd">60,000</price>
          <horsePower>6000</horsePower>
          <fuelCapacity units="gallons">13.5</fuelCapacity>
        </make>
      </company>
      <company name="Mercedes">
        <make name="benz">
          <model>test model</model>
          <price currency="usd">30,000</price>
          <horsePower>5000</horsePower>
          <fuelCapacity units="gallons">15.5</fuelCapacity>
        </make>
      </company>
    </cars>
    After creating this files save it. And then load it in the VC++ program, remember that you have to import some related libraries also. Then make a new Visual C++ project called XMLDOMFromVC, and in the In the MFC AppWizard, describe the project as being a dialog-based application.

    Code:
    BOOL CXMLDOMFromVC::InitInstance()
    {
     AfxEnableControlContainer();
    
     // .. statements 
    
     ::AfxOleInit();
    
     //..statements
    return FALSE;
    }

  5. #5
    Join Date
    May 2009
    Posts
    527

    Re: How to export data to XML from the visual C++

    VC++.NET Data Retrieval and Export Application, allows a user to save the records in the grid to XML. And you can choose that data from almost each applications like either a SQL Server or Oracle or the Microsoft Access etc. And this is the application that you can download from the internet also and I have seen that on internet like you can download it for free also as a thirty days trial period.

  6. #6
    Join Date
    May 2009
    Posts
    637

    Re: How to export data to XML from the visual C++

    See I have another idea also through which you can do the same, for that first of all you have to develop one class which will behave as usual std::stream but as well follow all the needed XML markings.
    Refer this code, and let me tell you this is just as an example, of course you have to make changes in your program, but before that include this library.

    Code:
    #include "engine.h"
    #define BUFSIZE 256
    ofstream a("example.xml");
    XmlStream xml(a);
    
    xml << prolog() 
    
      << tag("example-tag")
    
        << tag("some-tag") 
    
          << attr("int-attribute") << 1234
          << attr("double-attribute") << 345.789
          << chardata() << "This is the text"
        << endtag()
    
        << tag("empty-self-closed-tag") 
        << endtag()
    
        << tag() << "computed-name-tag"
          << attr("text-attribute") << "a byte of text"
        << endtag()
    
        << tag("deep-tag") 
          << tag("sub-tag-2")
            << tag("sub-tag-3")
        << endtag("deep-tag"); 
    After this, used it in the VC++ program
    template<class t> XmlStream& operator<<(const t& value) {
      
      if (stateTagName == state)
     
        tagName << value;
    
      s << value;
      return *this;
    }

Similar Threads

  1. How to Export and Import DATA from Tally
    By SoftwareGuy in forum Tips & Tweaks
    Replies: 3
    Last Post: 08-03-2012, 03:18 AM
  2. Import & Export Data
    By AnkitSingh007 in forum Off Topic Chat
    Replies: 2
    Last Post: 09-12-2011, 04:18 PM
  3. How to export DHCP data to notepad
    By Jacek in forum Networking & Security
    Replies: 2
    Last Post: 25-11-2008, 06:20 PM
  4. Export Project Data to Excel
    By Asgar in forum Microsoft Project
    Replies: 3
    Last Post: 20-06-2007, 07:56 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,660,068.19422 seconds with 17 queries