You load an XML document into an instance of the XmlDocument class. You add elements to it.
You need to validate the changes that you made to the XML document against a schema. You do not want to create a new instance of the Document Object Model (DOM).
What should you do?
A) Create an XmlNodeReader by using the XML document. Set the validation settings on the XmlReaderSettings object. Create a validating reader that wraps the XmlNodeReader object.
B) Save the contents of the XML document to the file system. Create a new instance of the XmlDocument class. Call the Load method, and pass in the file path of the recently modified XML document.
C) Create an XmlNodeReader by using the elements of the XML document that changed. Set the validation settings on the XmlReaderSettings object. Create a validating reader that wraps the XmlNodeReader object.
D) Save the contents of the XML document to a string. Create a new instance of the XmlDocument class. Call the LoadXml method, and pass in the string representation of the recently modified XML document.
A- seems to be correct, the XmlReaderSettings allows for setting the schema to be used and you can then just use a XmlReader that would use that. I am assuming that the XmlNodeReader could do the same.
B- would work, but seems excessive amount of time to accomplish.
C- Same as A, but only looks at the newly created nodes, this seems to be the quickest. The XmlNodeReader is suppose to keep track of where in the schema the current not would be referencing.
D- inefficient, holding xml in string is probably not the best choice.
A good way of doing this was found on MSDN: http://support.microsoft.com/kb/318504/
No comments:
Post a Comment