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.