Micro Focus QTP (UFT) Forums
Problem with creating an XML file - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: Problem with creating an XML file (/Thread-Problem-with-creating-an-XML-file)



Problem with creating an XML file - Orbitz1 - 09-21-2009

Hi.
I was trying to create an XML file through QTP using XMLUtil, i managed to create the XML except for one problem, the file is created without the XML declaration, i can't figure out how to add the xml declaration to the file.
Anyone knows?


RE: Problem with creating an XML file - Saket - 09-22-2009

You can use 'AddDeclaration' method. This will add the xml declaration to your xml doc.
see the code below
Code:
Set oXML = XMLUtil.CreateXML
oXML.Loadfile "C:\books.xml" 'replace with your xml path
oXML.AddDeclaration "1.0","UTF-8","no"
oXML.SaveFile  "C:\books.xml" 'replace with your xml path