0

I'm trying to parse though an SVG file in vbscript. When using a normal XML-file my code is working but when using a SVG file no tags can be found. Is it possible to parse trough a SVG file or even manipulate it?

Set xmlDoc = CreateObject("Msxml2.DOMDocument.6.0")

xmlDoc.Async = False
xmlDoc.setProperty "ProhibitDTD", False
xmlDoc.resolveExternals = False
xmlDoc.validateOnParse = False

xmlDoc.load("pathToSVG/XML")

Set root = xmlDoc.GetElementsByTagName("svg")

for each elem in root
msgBox elem.Tagname
Next


Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Tobias
  • 3
  • 2
  • 1
    Does this answer your question? [XML File parsing using the VBScript](https://stackoverflow.com/questions/23809494/xml-file-parsing-using-the-vbscript) – user692942 Jul 26 '21 at 17:36
  • Does this answer your question? [VBScript, MSXML and Namespaces](https://stackoverflow.com/a/1199794/692942) – user692942 Jul 26 '21 at 17:37
  • 1
    Would help to see the structure of the SVG file, if you have elements in there from various namespaces they will need declaring. – user692942 Jul 26 '21 at 17:39

1 Answers1

-2

Your script works with SVG files if you use msxml3 by changing the first line to:

Set xmlDoc = CreateObject("Msxml2.DOMDocument")

Or

Set xmlDoc = CreateObject("Msxml2.DOMDocument.3.0")
LesFerch
  • 1,540
  • 2
  • 5
  • 21
  • 1
    They are already using `Msxml.DOMDocument.6.0`, you suggesting they downgrade? – user692942 Jul 26 '21 at 17:34
  • Pretty sure this isn’t the fix and it’s related to them not declaring the namespaces in the file. This happens with any complex XML structure in VBScript the MSXML needs to understand what namespaces an element comes from before it will load it. – user692942 Jul 26 '21 at 18:23
  • 1
    Thank you, changing it to msxml2 3.0 worked for me! – Tobias Jul 27 '21 at 11:05