dcsimg
A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: open and edit existing xml

  1. #1
    Junior Member
    Join Date
    Jul 2009
    Posts
    20

    open and edit existing xml

    what is the best practise to open/load an existing xml-file and to append new child elements and save the edited xml-file in flash?

    i am working with AS2.
    is the xml object "sockets" good for that? or the component "xml connector"?

    help would be greatly appreciated.

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    code available at this link -
    http://www.jackleaman.co.uk/test/wri...hange_xml.html

    make your edits and Save. Refresh or close the browser and on return
    your edited xml file will still hold your editing.

  3. #3
    Junior Member
    Join Date
    Jul 2009
    Posts
    20
    thx. worked just fine!

  4. #4
    Junior Member
    Join Date
    Jul 2009
    Posts
    20
    another short and hopefully easy question regarding this topic.

    in my application i am working with a variable/object called "doc" of the type "XML".
    in this variable i load the XML-files i am working with (e.g. appending new elements...).

    now sometimes i need a completely new xml to be created. so i have to clear the doc-object because i need an empty doc-variable to build my new xml-file. how can i do this?

    something like:
    "doc:XML = null" ? but i think then it gets destroyed in the memory, which is not good...

    EDIT: i want to be able to work with a global XML-object called "doc".
    i read in another thread that i could do:
    Code:
    var doc:XML = new XML();
    but this won't work because this "doc:XML" won't reference to my doc:XML which i used before..

    so how can i create a global Object of the type XML?
    _global.doc:XML = new XML(); does not work. i want to be able to work with this global doc:XML-object everywhere in my application without the need to pass it to each function. then again i would need the ability to clear it somehow, which should be possible.
    Last edited by Beta2k; 08-21-2009 at 02:45 PM.

  5. #5
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    try - _global.doc = new XML();

  6. #6
    Junior Member
    Join Date
    Jul 2009
    Posts
    20
    thx for your help again! :-)

    there still seems to be a problem.

    i am also working with an event-listener who listens to "_global.doc.onload", which looks like this:

    Code:
    _global.doc.onLoad = function(success) {
    //do something here
    };
    after i use "_global.doc = new XML();" for the first time after running my application the onLoad.eventListener seems not to work anymore, since when i do "_global.doc.load(path2file)" after "_global.doc = new XML();" it won't execute the "_global.doc.onLoad" method...

    the code works like this:
    _global.doc = new XML(); => then create a new xml file and save it to harddisk ==> then i want to load it again, which does not work anymore because he wont execute the _global.doc.onload eventhandler anymore after i do "_global.doc = new XML();"...

    should that work normally?
    Last edited by Beta2k; 09-01-2009 at 08:23 AM.

  7. #7
    Junior Member
    Join Date
    Jul 2009
    Posts
    20
    i think i solved it :-) yay!

    after doing
    Code:
    _global.doc = new XML();
    i am defining a "new" onload handler which then works!

    would you also have solved it that way?

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