A Flash Developer Resource Site

Results 1 to 14 of 14

Thread: parseXML

  1. #1
    ...in human form
    Join Date
    Aug 2002
    Posts
    188
    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.

  2. #2
    ...in human form
    Join Date
    Aug 2002
    Posts
    188
    whoops, lost the xml tags in that. in the quotes should be the open and close tag, between which is the variable file.

  3. #3
    Senior Member
    Join Date
    Feb 2001
    Location
    Provo, Utah
    Posts
    1,112

    Uhm...

    If you put spaces after the opening tags you'll be fine.

    < top>
    < inside/>
    < /top>

  4. #4
    ...in human form
    Join Date
    Aug 2002
    Posts
    188
    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?


  5. #5
    Senior Member
    Join Date
    Feb 2001
    Location
    Provo, Utah
    Posts
    1,112

    Uhm...

    +file+

  6. #6
    ...in human form
    Join Date
    Aug 2002
    Posts
    188
    thank you. sometimes its the simple things.

  7. #7
    ...in human form
    Join Date
    Aug 2002
    Posts
    188
    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?

  8. #8
    Senior Member
    Join Date
    Feb 2001
    Location
    Provo, Utah
    Posts
    1,112

    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...

  9. #9
    ...in human form
    Join Date
    Aug 2002
    Posts
    188
    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?

  10. #10
    Senior Member
    Join Date
    Feb 2001
    Location
    Provo, Utah
    Posts
    1,112

    Uhm...

    Humm.... Huh??

    How about a pseudo-code example of what you'd like to do...

  11. #11
    Senior Member tupps's Avatar
    Join Date
    Jan 2001
    Location
    Melbourne
    Posts
    2,035
    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

  12. #12
    ...in human form
    Join Date
    Aug 2002
    Posts
    188
    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.


  13. #13
    Senior Member
    Join Date
    Feb 2001
    Location
    Provo, Utah
    Posts
    1,112

    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.

  14. #14
    ...in human form
    Join Date
    Aug 2002
    Posts
    188
    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.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center