www.webdeveloper.com
Results 1 to 4 of 4

Thread: Editing XML file from HTML table

  1. #1
    Join Date
    Jan 2010
    Posts
    2

    Editing XML file from HTML table

    I have two files of which one is an html file and the other an xml file. I am loading the xml file into a table for display within the html table. This works well. However, I would like to be able to edit data within the table and then save back to the xml document. So basically, I have a couple questions. I am thinking of using javascript, but I not sure how to edit the data.

    1 - How can I make the fields in the table editable?

    2 - If I can make the fields editable how can I save the changes to the xml file?

    Here are my two files:
    [HTML]
    <html>
    <body>
    <xml src="simplexsl.xml" id="refTable"></xml>
    <table border="1" style="font: 10pt Verdana, sans-serif;
    color:navy; background-color:rgb(255,255,200)"
    cellpadding="5" datasrc="#refTable" align="center">
    <thead>
    <td>Name</td>
    <td>Price</td>
    <td>Description</td>
    </thead>
    <td>
    <span
    datafld="name"></span>
    </td>
    <td>
    <span
    datafld="price"></span>
    </td>
    <td>
    <span
    datafld="description"></span>
    </td>
    </tr>
    </table>
    </body>
    </html>

    [XML]
    <?xml version="1.0" encoding="ISO8859-1" ?>
    <breakfast-menu>
    <food>
    <name>Belgian Waffles</name>
    <price>$5.95</price>
    <description>two of our famous Belgian Waffles with plenty of real maple syrup</description>
    <calories>650</calories>
    </food>
    <food>
    <name>Strawberry Belgian Waffles</name>
    <price>$7.95</price>
    <description>light Belgian waffles covered with strawberrys and whipped cream</description>
    <calories>900</calories>
    </food>
    <food>
    <name>Berry-Berry Belgian Waffles</name>
    <price>$8.95</price>
    <description>light Belgian waffles covered with an assortment of fresh berries and whipped cream</description>
    <calories>900</calories>
    </food>
    <food>
    <name>French Toast</name>
    <price>$4.50</price>
    <description>thick slices made from our homemade sourdough bread</description>
    <calories>600</calories>
    </food>
    <food>
    <name>Homestyle Breakfast</name>
    <price>$6.95</price>
    <description>two eggs, bacon or sausage, toast, and our ever-popular hash browns</description>
    <calories>950</calories>
    </food>
    </breakfast-menu>

    Thanks

  2. #2
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,278
    Internet, intra or stand-alone, local file?
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

  3. #3
    Join Date
    Jan 2010
    Posts
    2

    Edit XML file from HTML Table

    Currently it is a local file. My plan is to return it from a web service, but not at this time. I found an example below that gives a better idea of what I am trying to do with the table. Basically, I would like to have a javascript button on the row of which would then populate the fields for editing based on the row I select the button in where I could then save them to the xml file after selecting a save button.

    If you have a better idea I am willing to try it.

    http://apps.tibco.com/dwr/people/index.html

    Thanks

  4. #4
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,278
    If it's going to be on the web then JavaScript is way much not the way to go. JavaScript or not you'll need a server side script to handle the data so you might as well just implement this as a FORM and not worry about the JavaScript not working.
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles