Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
| Search | Today's Posts | Mark Forums Read
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old January 19th, 2005, 06:01 AM
Authorized User
Join Date: Jan 2005
Location: Kolkata, West Bengal, India.
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to Edit Attribute Value in XML by ASP.Net

Hi all,
          I want to edit the value of Product_Name and Price Where
Product_Id = "P1", Please tell me what is the procedure.

My xml file describe below:------------------

        <?xml version="1.0" encoding="utf-8" standalone="yes"?>
  <ORDER Product_Id="P1" Product_Name="SINK1" Price="1000" />
  <ORDER Product_Id="P2" Product_Name="SINK2" Price="2000" />
  <ORDER Product_Id="P3" Product_Name="SINK3" Price="3000" />
  <ORDER Product_Id="P4" Product_Name="SINK4" Price="4000" />
  <ORDER Product_Id="P5" Product_Name="SINK5" Price="5000" />
  <ORDER Product_Id="P6" Product_Name="SINK6" Price="6000" />

                     Waiting for reply
Thanks in Advance.

Sibaji Basak.

  #2 (permalink)  
Old January 20th, 2005, 02:07 AM
Registered User
Join Date: Jan 2005
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts

<script language="javascript">
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM")

var orderlist = xmlDoc.getElementsByTagName("ORDER-LIST")
var orderListLen = orderlist.item(0).childNodes.length

  var childNodes = orderlist.item(0).childNodes(i).nodeName
  var attribProdId= orderlist.item(0).childNodes(i).getAttribute("Prod uct_Id")
  var attribProdName=orderlist.item(0).childNodes(i).get Attribute("Product_Name")
  var attribPrice = orderlist.item(0).childNodes(i).getAttribute("Pric e")
  document.write("( " + attribProdId + " ) " + " <a href='#' id='" + i + "'name='" + attribProdId + "' onclick='changeData(this.id)'>" + attribProdName + "</a> Price = " + attribPrice + "<br>")

function changeData(Id)
  var SetPrice = parseInt(prompt("Enter the new Price for this product : ",""))
  var SetProdName = prompt("Enter the new Name for this product : ","")

    //The new Price and Product Name would be saved here
    orderlist.item(0).childNodes(Id).setAttribute("Pro duct_Name",SetProdName)
    orderlist.item(0).childNodes(Id).setAttribute("Pri ce",SetPrice)

    //Update the xml file

    alert("New Price = " + SetPrice + " New Product Name = " + SetProdName)



If u can get the hint from the above code u can surely go ahead and do it in ASP.NET. What u need to do is generate hyperlinks or whatever using ASP.NET and add an "onclick" event using ASP.NET and then call a function called changeData(Id) using the same and the rest can be done using javascript. Any other queries are welcome.

Wilbur J. Pereira

Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel sheet accessing(edit/update) in asp.net hemant.dna ASP.NET 1.0 and 1.1 Basics 0 January 31st, 2007 07:37 AM
how to edit and update my access db using asp.net method ASP.NET 1.0 and 1.1 Basics 4 April 25th, 2005 03:03 PM
VB.NET: Get the Attribute and Text out from Xml toytoy Pro VB.NET 2002/2003 0 October 25th, 2004 11:03 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.