-
is it possible to input variables into a parseXML line. i've tried but keep getting errors.
Symbol=inputscreen, Layer=code, Frame=1: Line 3: ')' or ',' expected
new.parseXML("<AD><ADID>"+file"</ADID></AD>");
where file is a variable for an input text.
-
whoops, lost the xml tags in that. in the quotes should be the open and close tag, between which is the variable file.
-
Uhm...
If you put spaces after the opening tags you'll be fine.
< top>
< inside/>
< /top>
-
okay the line that gets the error is:
new.parseXML ("< ad>" + file "< /ad>")
the error is the one listed above. 'file' is a variable from an input window. can the parser interpret the variable?
-
Uhm...
-
thank you. sometimes its the simple things.
-
a few follow up questions:
- are the tags put in the parseXML string actual nodes now or are they fake?
- if they are real tags can they be referred to outside of the parseXML? by example if I want to give one an attribute.
- can this XML element now be sent to be saved as a new external text/XML file on the server via php?
-
Uhm...
I thin kyou're trying to ask if the string is now an XML Object, since it's been 'parsed'...
You'll probably want to spend some time looking over the documentation for XML Object, and XML Node. That should get you started...
-
again thanks for all of your help. i'm a bit clearer now as to parsing, but i'm trying to determine if this is the practical way for what i'm working on. my question now is whether parsing can be done dynamically? can i write out a parse string which can change the output depending upon user input?
-
Uhm...
Humm.... Huh??
How about a pseudo-code example of what you'd like to do...
-
I think this is a question of whether you can (please correct if wrong, which I usually am):
Initial Code:
String --> XML Parse --> XML Objects
Change String, will this automagically change the XML Objects. Which in this case it will not. The XML object no longer references its input string once it has been parsed.
Thanks
Luke
-
an example:
new.parseXML ("< id >"+id+"< /id >< items >< folder1 >"+folder1+"< /folder1 >< folder2 >< sheet1 >"+sheet1+"< /sheet1 >< /folder2 >< folderi > .... < /folder >< /items> >")
the issue is the number of items is determined by the user, as is whether there are contents in the folder and what those contents are, if they include sheets etc... as such i need to be able to have my parser account be able to handle when there is only two folders with one item each and when there are 20 folders with a hundred items each. on top of this all of the tag values are variables which the user inputs. thus the whole string must be dynamic based on user input.
thanks for sticking with me on this.
-
Uhm...
parseXML is not the only way to create XML Objects... look into the XML Object some more and you'll find methods like - appendChild, and createElement.
You can have these method in a loop that goes over everything the user would add.
-
i actually started out using appendChild and ran into tons of complications getting the variables to the Children properly. I kept ending up with the element values being null because they refferred to the empty input variable not the completed one. i'm thinking its just a script placement issue and have started over from scratch trying to get all of the variables first before trying to parse them out into xml objects. again however the issue is how the variables themselves change per usage.