Add a Text in exiting xml node in asp.net

Posted by Gopal_nivas under ASP.NET on 1/11/2011 | Points: 10 | Views : 1597 | Status : [Member] | Replies : 1
hi..
i have the xml document like this..

<PRODUCT>
<TITLES>
<TITLEVALUE NAME="FGDGDFDFG" TYPE="Circle" WIDTH="100" HEIGHT="200">
<PROPERTIES>
<PROPERTY DATA="text" VALUE="WELCOME"/>
<PROPERTY DATA="indent" VALUE="2"/>

</PROPERTIES>
</TITLEVALUE>
</TITLES>
</PRODUCT>

I WAS STORED THIS XML INTO DATABASE TABLE..

HERE I WANT TO JUST ADD A "PRODUCTURL=1.JPG" IN TITLES TAG.
I.E)
<PRODUCT>
<TITLES PRODUCTURL="1.JPG">
<TITLEVALUE NAME="FGDGDFDFG" TYPE="Circle" WIDTH="100" HEIGHT="200">
<PROPERTIES>
<PROPERTY DATA="text" VALUE="WELCOME"/>
<PROPERTY DATA="indent" VALUE="2"/>

</PROPERTIES>
</TITLEVALUE>
</TITLES>
</PRODUCT>

HERE REMAING NODE VALUES ARE SAME..

HOW TO DO THIS..

NEED UR SUGGESTIONS

REGARDS
GOPAL.S




Responses

Posted by: Suresh.mekkattil on: 1/11/2011 [Member] Bronze | Points: 25

Up
0
Down
Hi,

You can use the following
XmlNode node = doc.SelectSingleNode("//PRODUCT/Title");
XmlElement ele = doc.CreateElement("aaa");

XmlAttribute newAttribute = doc.CreateAttribute("b","ccc","http://www.w3.org/1999/XSL/Transform");
newAttribute.Value = "ddd";

ele.Attributes.Append(newAttribute);

node.InsertBefore(ele, node.LastChild);




-----
Suresh M

Gopal_nivas, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response