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. XML / XSL
  4. Validating xml against schema using System.Xml in unmanagedC++

Validating xml against schema using System.Xml in unmanagedC++

Scheduled Pinned Locked Moved XML / XSL
xmlhelpc++database
4 Posts 2 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.
  • M Offline
    M Offline
    Murlai
    wrote on last edited by
    #1

    I am new to the System.Xml, I am converting the code existing in MSXML parser code to System.Xml in unmanaged C++. I am able to load the file with the Load() function, and I am getting the validate error from the catch block. there is no problem in loading the xml documet into the "m_docPtr" this is System.Xml.XmlDocument type. After loading the xml document into "m_docPtr", I will change the values of some child elements. Now I want to validate the document again with the new chages. In MSXML parser Validate() methode in the document class to do the above, Can I get the similar method or some procedure with System.Xml classes. Thanks.

    D 1 Reply Last reply
    0
    • M Murlai

      I am new to the System.Xml, I am converting the code existing in MSXML parser code to System.Xml in unmanaged C++. I am able to load the file with the Load() function, and I am getting the validate error from the catch block. there is no problem in loading the xml documet into the "m_docPtr" this is System.Xml.XmlDocument type. After loading the xml document into "m_docPtr", I will change the values of some child elements. Now I want to validate the document again with the new chages. In MSXML parser Validate() methode in the document class to do the above, Can I get the similar method or some procedure with System.Xml classes. Thanks.

      D Offline
      D Offline
      DavidNohejl
      wrote on last edited by
      #2

      Hi Murlai, do you mean System.Xml.ValidatingReader? Or do I miss something? :) In post below[^] you can see how to use it. In case you saw it, or even you know System.Xml.ValidatingReader, and it can't be used for some reason, plz tell me.. I don't do unmanaged so I can lear<n something :) best regards, David 'DNH' Nohejl Never forget: "Stay kul and happy" (I.A.)

      M 1 Reply Last reply
      0
      • D DavidNohejl

        Hi Murlai, do you mean System.Xml.ValidatingReader? Or do I miss something? :) In post below[^] you can see how to use it. In case you saw it, or even you know System.Xml.ValidatingReader, and it can't be used for some reason, plz tell me.. I don't do unmanaged so I can lear<n something :) best regards, David 'DNH' Nohejl Never forget: "Stay kul and happy" (I.A.)

        M Offline
        M Offline
        Murlai
        wrote on last edited by
        #3

        this->m_docPtr = new XmlDocument(); this->m_xmlTestReader = new XmlTextReader(strFileName); this->m_xmlValidateReader = new XmlValidatingReader(this->m_xmlTestReader); // load the strFileName into the document this->m_docPtr->Load(this->m_xmlValidateReader); System::String __gc *strParam = new String("//*/Range"); System::Xml::XmlNode *nodePtr = m_docPtr->SelectSingleNode(strParam); System::String __gc *strVale = new String("-1290"); nodePtr->set_InnerText(strVale); // Now I want validate the data.. ---------------------------- When loading the xml file the Range is some positive value, if it is negative when loading the exception comming with error message, this is fine for me. I want validae after modifying the Range value to -1290 is not valied as per the .xsd schema. In the above How can I validate? Please help.. Thanks.

        D 1 Reply Last reply
        0
        • M Murlai

          this->m_docPtr = new XmlDocument(); this->m_xmlTestReader = new XmlTextReader(strFileName); this->m_xmlValidateReader = new XmlValidatingReader(this->m_xmlTestReader); // load the strFileName into the document this->m_docPtr->Load(this->m_xmlValidateReader); System::String __gc *strParam = new String("//*/Range"); System::Xml::XmlNode *nodePtr = m_docPtr->SelectSingleNode(strParam); System::String __gc *strVale = new String("-1290"); nodePtr->set_InnerText(strVale); // Now I want validate the data.. ---------------------------- When loading the xml file the Range is some positive value, if it is negative when loading the exception comming with error message, this is fine for me. I want validae after modifying the Range value to -1290 is not valied as per the .xsd schema. In the above How can I validate? Please help.. Thanks.

          D Offline
          D Offline
          DavidNohejl
          wrote on last edited by
          #4

          Did you read my previous post at all? http://www.codeproject.com/script/comments/forums.asp?forumid=3421&select=969989&df=100#xx969989xx[^] Focus on ValidatingEvent and XmlValidatingReader.Read(). Translate it into unmanaged and you're done! Only thing you need to change is constructor for XmlValidatingReader. See MSDN[^] (At least I hope so) David Never forget: "Stay kul and happy" (I.A.)

          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