Welcome! Log In Create A New Profile

Advanced

[WD21]Working with XSD file - SOLVED

Posted by ericus 
[WD21]Working with XSD file - SOLVED
November 14, 2021 07:40AM
Good afternoon

To solve the below issue was actually easy.

Create a temporary xmlDocument variable from the same XSD. Everytime you want to empty the original xmlDocument variable just put Original = Temporary.

I have no problem importing an XML file in my project, adding all the values in the different nodes and saving the resulting XML file.

What I am struggling with is clearing the values of the different nodes after saving the XML or alternatively loading the XSD file again.

Below is an example for the Help. I am running similar code within a FOR Loop but I cannot put cMyDoc is xmlDocument <description="person.xsd"> in the 1st line after the loop as there are other sub-loops running within the FOR loop. Only if certain conditions are met must values be cleared and I start with a clean xmlDocument.

cMyDoc is xmlDocument <description="person.xsd">

cMyDoc.person.lastname = "Moore"
cMyDoc.person.firstname = "Vince"
cMyDoc.person.dob = "19710211"
cMyDoc.person.email[1] = "vince.moore@mydomain.com"
cMyDoc.person.email[2] = "vince.moore@otherdomain.com"

XMLSave(cMyDoc, fExeDir() + ["\"] + "test.xml")

// Or with an intermediate check:
IF XMLValidDocument(cMyDoc) = True THEN
XMLSave(cMyDoc, fExeDir() + ["\"] + "test.xml")
IF ErrorOccurred = True THEN
Error("Unable to save the XML document", ErrorInfo())
ELSE
Info("OK", fExeDir() + ["\"] + "test.xml")
END
ELSE
Error("The XML document is invalid", ErrorInfo())
END

cMyDoc = Null clear the complete structure of the XML file so when you add the line cMyDoc.person.lastname = "Moore" again it will fail.

Any pointerswill be most welcome.


Ericus Steyn



Edited 1 time(s). Last edit at 11/15/2021 09:30AM by ericus.
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: