How to add nodes in javascript to xml ?

Discussion in 'JavaScript' started by micheal9000, Jun 3, 2009.

  1. #1
    I have xml file
    
    <?xml version="1.0" encoding="utf-8"?>
    <chat>
    	<user>HoangThanh:</user>
    	<content>Welcome !</content>
    </chat>
    <chat>
    	<user>Guest:</user>
    	<content>Hi !</content>
    </chat>
    
    Code (markup):
    I want to add node <chat></chat> with its data <user></user> and <content></content>, how can I do ? Please help me !
     
    micheal9000, Jun 3, 2009 IP
  2. xlcho

    xlcho Guest

    Messages:
    532
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Open the file with a text editor and just write them :D:D
    If you want someone to really help you - you better tell how this file is generated, post some code or something like this.
     
    xlcho, Jun 3, 2009 IP
  3. micheal9000

    micheal9000 Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    In my form, have one textinput and one button, i want that, when click on button, all text in textinput will be add into xml file (node content - and node user - generate somthing ...). Just only that ! Can you help me plz ! :)
     
    micheal9000, Jun 3, 2009 IP
  4. Unni krishnan

    Unni krishnan Peon

    Messages:
    237
    Likes Received:
    9
    Best Answers:
    2
    Trophy Points:
    0
    #4
    Hi Micheal,

    If you want to edit the xml with javscript, then you should know that,
    1. xml editing through javscript is possible on server side.
    2. on client side though, you can edit the xml only in memory, and i think you can't chnage anything on the client's computer as browser security prevents it.

    But i think you are looking for a solution on local system. In that case javascript can be used.

    Hope this link helps.

    "http://www.w3schools.com/dom/dom_intro.asp"
     
    Unni krishnan, Jun 4, 2009 IP