![]() |
XML Parser
parseXML()
Description Here is a little code that can transform an XML file into something that GScript can understand. The format is similar to that of ActionScript's XML Object. XML.childNodes is an array of entities within the XML object. XML.parent is the parent entity of the XML object. XML.nodeName is the name of entity within the XML object. XML.nodeType is an integer representing the type of the XML object (1 for plain text, 2 for XML entity). XML.nodeValue is the XML object / plain text nested within the XML object. XML.attributes is a string in the pattern of var1=val1&var2=val2&...&varN=valN. Variables can also be read with XML.attributes.var. XML.xmlDecl is the XML declaration of the XML object. XML.docTypeDecl is the DTD of the XML object. Except nodeType, None of these values are read only. The Code PHP Code:
with(var) this = parseXML(strXML); Parameters strXML A string of XML or well-formed HTML. Returns The parameter passed to the function. Example PHP Code:
The scene is set; to remake the XML file, you're going to have to get creative. Post problems / comments / etc. |
Sounds interesting and useful
A little improvement for using the requesturl object: I think you can use "obj.fulldata" instead of merging the obj.data lines: with(me) this = parseXML(obj.fulldata) |
Thanks, I was not aware that existed.
|
Wouldn't it work if you did it like this:
PHP Code:
Not sure if setting 'this' is a wise thing to do |
Quote:
e: PHP Code:
Some additions:
|
Ah, I see what it's doing now, but I still stand by my saying I don't think you should be setting this, especially if you're just setting it as a string. Why not just make it set a 'me.parsedXML', and return an error code?
PHP Code:
|
Quote:
PHP Code:
Yes, it is possible to change that, but it would be reparsing bits that have already been parsed. And setting this is not harming anything. I am merely setting a variable a different way. PHP Code:
Quote:
e: temp.before = strXML.substring(temp.test); should be temp.before = strXML.substring(0,temp.test); in the code. |
| All times are GMT +2. The time now is 04:53 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.