Lazycat Posted August 24, 2005 Posted August 24, 2005 I have one program that keep it's settings in the XML file. This is semi-valid file, because it's absent declaration, though file contain symbols that prevent MSXML parser to parse it. So for correct parsing I need to apply declaration with needed encoding to the loaded file. Only examples I googled was NET examples. NET allow create declaration with the CreateXmlDeclaration and apply it to loaded document. How to make this in usual way? Of course, I can merge declaration string with file content and write it to new file, but maybe exists right way to do it? Koda homepage ([s]Outdated Koda homepage[/s]) (Bug Tracker)My Autoit script page ([s]Outdated mirror[/s])
Valik Posted August 24, 2005 Posted August 24, 2005 The XML declaration is just a processing instruction. MSXML has a method for creating a processing instruction.
Lazycat Posted August 24, 2005 Author Posted August 24, 2005 Thanks, exactly! Anyway, loading with Load method not works, so I used LoadXML instead - seems it's load any well formated data. Below is code for those who interested: $oXml = ObjCreate("Msxml2.DOMdocument.3.0") $oXml.LoadXML(FileRead("servercfg.xml", FileGetSize("servercfg.xml"))) $oXmlRoot = $oXml.documentElement $oXmlDecl = $oXml.createProcessingInstruction("xml", 'version="1.0" encoding="UTF-8"') $oXml.InsertBefore($oXmlDecl, $oXmlRoot) $oXml.Save("servercfg_new.xml") Koda homepage ([s]Outdated Koda homepage[/s]) (Bug Tracker)My Autoit script page ([s]Outdated mirror[/s])
webmedic Posted September 7, 2005 Posted September 7, 2005 I'm curious then with the example, I know nothing about using whatever you did to lood the msxml, but if you wanted to parse an xml file and use it for a config file instead of say an ini file what commands would you use to iterate through the fields and get the data out of an xml file?
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now