FlecheBleu Posted October 17, 2020 Posted October 17, 2020 Hello Community, I'm stuck on this namespace thing, I think !!! I would like to read an XML file that contains SVG markup. <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg version="1.2" width="149.2mm" height="211.7mm" viewBox="0 0 14920 21170" preserveAspectRatio="xMidYMid" fill-rule="evenodd" stroke-width="28.222" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg" xmlns:ooo="http://xml.openoffice.org/svg/export" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:presentation="http://sun.com/xmlns/staroffice/presentation" xmlns:smil="http://www.w3.org/2001/SMIL20/" xmlns:anim="urn:oasis:names:tc:opendocument:xmlns:animation:1.0" xml:space="preserve"> <defs>...</svg> I have this piece of code to check the loading of the : $oXML = ObjCreate('Msxml2.DOMDocument.6.0') ; Setting File IN/OUT $Fichierin="e:\in.svg" $Fichierout= StringReplace($Fichierin,".","-maj.") ; Calling XML File $oXML.load($Fichierin) $oXML.setProperty("SelectionLanguage", "XPath") $strNameSpc = "xmlns:svg='http://www.w3.org/2000/svg'" $oXML.setProperty("SelectionNamespaces", $strNameSpc) $oRoot = $oXML.selectSingleNode("//svg:defs") ConsoleWrite("$oRoot.xml=[" & $oRoot.xml & "]" & @CRLF) Result => empty. On the other hand, if I remove the header from the SVG file like this: <svg version="1.2" width="149.2mm" height="211.7mm" viewBox="0 0 14920 21170" preserveAspectRatio="xMidYMid" fill-rule="evenodd" stroke-width="28.222" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg" xmlns:ooo="http://xml.openoffice.org/svg/export" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:presentation="http://sun.com/xmlns/staroffice/presentation" xmlns:smil="http://www.w3.org/2001/SMIL20/" xmlns:anim="urn:oasis:names:tc:opendocument:xmlns:animation:1.0" xml:space="preserve"> <defs>... </svg> it's ok I have the XML file that can be used in Autoit. Do you have any research leads? Thanks in advance
TheXman Posted October 17, 2020 Posted October 17, 2020 (edited) <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> Remove the DOCTYPE line from your svg file and your script should work. The reason your script fails with the DOCTYPE line is because the .Load method generates an error due to the DTD. Therefore, you do not have a valid XML document object to work with. So any statements referencing the XML document object will fail also. Side Note: Unfortunately the SVG DTDs are a source of so many issues that the SVG WG has decided not to write one for the upcoming SVG 1.2 standard. In fact SVG WG members are even telling people not to use a DOCTYPE declaration in SVG 1.0 and 1.1 documents. Instead always include the 'version' and 'baseProfile' attributes on the root <svg> tag, and assign them appropriate values. https://dev.w3.org/SVG/profiles/2.0/publish/intro.html Edited October 17, 2020 by TheXman Fixed the content of the side note FlecheBleu 1 CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
FlecheBleu Posted October 18, 2020 Author Posted October 18, 2020 Thank you for the reference, I had come to this conclusion with one: _FileWriteToLine($Filein, 2, "<!--DOCTYPE REMOVED-->", 1) Thank's 😉
TheXman Posted October 18, 2020 Posted October 18, 2020 You're welcome CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
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