Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Read and Write to XML file using VC++

Read and Write to XML file using VC++

Scheduled Pinned Locked Moved C / C++ / MFC
c++xml
21 Posts 7 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • CPalliniC CPallini

    I noticed myself yesterday and thought about a CodeProject bug since it is an unbelievable: the article had about 22000 views and no vote.

    If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
    This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
    [My articles]

    N Offline
    N Offline
    Naveen
    wrote on last edited by
    #12

    I even tried another browser to check whether it is a bug or not... Any way it shows two votes now :)

    nave [OpenedFileFinder] [My Blog]

    CPalliniC 1 Reply Last reply
    0
    • N Naveen

      There is a save method for the IXMLDOMDocument. so can add nodes to the XML file using the appendChild function and when you are done adding all the nodes and sub nodes, you can call the save function, which will flush the content of the IXMLDOMDocument to the specified file in the XML format.

      nave [OpenedFileFinder] [My Blog]

      A Offline
      A Offline
      anna mathew
      wrote on last edited by
      #13

      Now Ive Created an Xml file..... By Adding new item(.xml) in project settings... Ive started with a dialog box.... on pressing ok..the file is opened... The CODE IS: void CXMLDOMFromVCDlg::OnBnClickedEnter() { XmlDocument *docXML = new XmlDocument; docXML->LoadXml(S""); } Ive Also added : #import <msxml.dll> named_guids using namespace MSXML; .................. in stdafx.h im doing this using MFC AppWizard..... this is not working...... im getting so many ERROR: : 'XmlDocument' : undeclared identifier : 'docXML' : undeclared identifier : syntax error : identifier 'XmlDocument' : left of '->LoadXml' must point to class/struct/union : managed targeted code requires '#using <mscorlib.dll>' and '/clr' option

      N 1 Reply Last reply
      0
      • N Naveen

        You have to use the XML DOM to read/write the XML using the vc++. See the article Introduction to Using the XML DOM from Visual C++[^]

        nave [OpenedFileFinder] [My Blog]

        A Offline
        A Offline
        anna mathew
        wrote on last edited by
        #14

        Also can u send me some sample code... to create XML File.... and Enter data to it

        1 Reply Last reply
        0
        • N Naveen

          I even tried another browser to check whether it is a bug or not... Any way it shows two votes now :)

          nave [OpenedFileFinder] [My Blog]

          CPalliniC Offline
          CPalliniC Offline
          CPallini
          wrote on last edited by
          #15

          I was just wondering who were the two 5 voters :rolleyes: :-D

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
          [My articles]

          In testa che avete, signor di Ceprano?

          S 1 Reply Last reply
          0
          • A anna mathew

            Now Ive Created an Xml file..... By Adding new item(.xml) in project settings... Ive started with a dialog box.... on pressing ok..the file is opened... The CODE IS: void CXMLDOMFromVCDlg::OnBnClickedEnter() { XmlDocument *docXML = new XmlDocument; docXML->LoadXml(S""); } Ive Also added : #import <msxml.dll> named_guids using namespace MSXML; .................. in stdafx.h im doing this using MFC AppWizard..... this is not working...... im getting so many ERROR: : 'XmlDocument' : undeclared identifier : 'docXML' : undeclared identifier : syntax error : identifier 'XmlDocument' : left of '->LoadXml' must point to class/struct/union : managed targeted code requires '#using <mscorlib.dll>' and '/clr' option

            N Offline
            N Offline
            Naveen
            wrote on last edited by
            #16

            anna mathew wrote:

            XmlDocument *docXML = new XmlDocument;

            no no. There is nothing called XmlDocument, it is IXMLDOMDocument. Please read the article I suggested...

            anna mathew wrote:

            By Adding new item(.xml) in project settings...

            you add xml to project settings?? why? :confused:

            nave [OpenedFileFinder] [My Blog]

            A 1 Reply Last reply
            0
            • CPalliniC CPallini

              I was just wondering who were the two 5 voters :rolleyes: :-D

              If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
              This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
              [My articles]

              S Offline
              S Offline
              SandipG
              wrote on last edited by
              #17

              Now it shows 3 votes :) BTW: Another member for THHB :D

              Regards, Sandip.

              CPalliniC 1 Reply Last reply
              0
              • N Naveen

                anna mathew wrote:

                XmlDocument *docXML = new XmlDocument;

                no no. There is nothing called XmlDocument, it is IXMLDOMDocument. Please read the article I suggested...

                anna mathew wrote:

                By Adding new item(.xml) in project settings...

                you add xml to project settings?? why? :confused:

                nave [OpenedFileFinder] [My Blog]

                A Offline
                A Offline
                anna mathew
                wrote on last edited by
                #18

                Instead of creating an XML file by coding... i tried to create it using AppWizard...thatz all ............ I made the changes u said.... void CXMLDOMFromVCDlg::OnBnClickedEnter() { IXMLDOMDocument *docXML = new IXMLDOMDocument; docXML->loadXML(S""); } but i get the following ERRORS...... ERROR: 'IXMLDOMDocument' : cannot instantiate abstract class ERROR: managed targeted code requires '#using <mscorlib.dll>' and '/clr' option Y is it????? **************************************************** I also tried::::::::: void CXMLDOMFromVCDlg::OnBnClickedEnter() { IXMLDOMDocumentPtr docPtr; docPtr.loadXML("XMLDOMFromVC.xml"); } but i get similar errors.....

                N 1 Reply Last reply
                0
                • A anna mathew

                  Instead of creating an XML file by coding... i tried to create it using AppWizard...thatz all ............ I made the changes u said.... void CXMLDOMFromVCDlg::OnBnClickedEnter() { IXMLDOMDocument *docXML = new IXMLDOMDocument; docXML->loadXML(S""); } but i get the following ERRORS...... ERROR: 'IXMLDOMDocument' : cannot instantiate abstract class ERROR: managed targeted code requires '#using <mscorlib.dll>' and '/clr' option Y is it????? **************************************************** I also tried::::::::: void CXMLDOMFromVCDlg::OnBnClickedEnter() { IXMLDOMDocumentPtr docPtr; docPtr.loadXML("XMLDOMFromVC.xml"); } but i get similar errors.....

                  N Offline
                  N Offline
                  Naveen
                  wrote on last edited by
                  #19

                  anna mathew wrote:

                  Instead of creating an XML file by coding... i tried to create it using AppWizard...thatz all

                  I dont know how you generate this codes, using App wizards. :confused: Any way this is the code for creating the IXMLDOMDocument.

                  IXMLDOMDocument* pXMLDoc = 0;
                  HRESULT hr = CoCreateInstance(CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER,
                  IID_IXMLDOMDocument, (void**)&pXMLDoc);

                  Please understand that this is COM. You cannot simply allocate a com pointer using the new.

                  nave [OpenedFileFinder] [My Blog]

                  1 Reply Last reply
                  0
                  • S SandipG

                    Now it shows 3 votes :) BTW: Another member for THHB :D

                    Regards, Sandip.

                    CPalliniC Offline
                    CPalliniC Offline
                    CPallini
                    wrote on last edited by
                    #20

                    I think the same: welcome Naveen [^]. :-D

                    If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                    This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                    [My articles]

                    In testa che avete, signor di Ceprano?

                    N 1 Reply Last reply
                    0
                    • CPalliniC CPallini

                      I think the same: welcome Naveen [^]. :-D

                      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                      [My articles]

                      N Offline
                      N Offline
                      Naveen
                      wrote on last edited by
                      #21

                      I am honored :laugh:

                      nave [OpenedFileFinder] [My Blog]

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups