Validating xml against schema using System.Xml in unmanagedC++
-
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.
-
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.
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.)
-
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.)
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.
-
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.
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.)