Any good example for write, read a specific node value from a xml file using C#.net

 

Is there any good example for write, read a specific node value from a xml file using C#.net

Regards
Anu Palavila
0
anupalavila
8/9/2008 10:35:16 AM
asp.net.xml-datasource 7181 articles. 0 followers. Follow

1 Replies
620 Views

Similar Articles

[PageSpeed] 11

> using System.Xml;
> using System.Xml.XPath;

> Insertion:
>         XmlDocument xmlDoc = new XmlDocument();
>         xmlDoc.Load(MapPath("~/App_Data/Users.xml"));
>         XmlDocumentFragment docFrag = xmlDoc.CreateDocumentFragment();
>         string id = txt_ins_uid.Text;
>         string name = txt_ins_uname.Text;
>         string pwd = txt_ins_pwd.Text;
>         docFrag.InnerXml =
> "<user><id>"+id+"</id><name>"+name+"</name><password>"+pwd+"</password></us­er>";
>         XmlNode childNode = xmlDoc.DocumentElement ;
>         childNode.InsertAfter(docFrag, childNode.LastChild);
>         xmlDoc.Save(MapPath("~/App_Data/Users.xml"));
> Updattion:
>         XmlDocument xmlDoc = new XmlDocument();
>         xmlDoc.Load(MapPath("~/App_Data/Users.xml"));
>         XmlNode name = xmlDoc.SelectSingleNode("/UsersList/user[id='" +
> txt_upd_uid.Text + "']/name");
>         name.InnerText = txt_upd_uname.Text;
>         XmlNode pwd = xmlDoc.SelectSingleNode("/UsersList/user[id='" +
> txt_upd_uid.Text + "']/password");
>         pwd.InnerText = txt_upd_pwd.Text;
>         xmlDoc.Save (MapPath("~/App_Data/Users.xml"));
> Deletion:
>         XmlDocument xmlDoc = new XmlDocument();
>         xmlDoc.Load(MapPath("~/App_Data/Users.xml"));
>         XmlNode root = xmlDoc.DocumentElement;
>         XmlNode childNode = xmlDoc.SelectSingleNode("UsersList/user[id='"
> + txt_del_uid.Text + "']");
>         root.RemoveChild(childNode);
>         xmlDoc.Save(MapPath("~/App_Data/Users.xml"));
> Users.xml:
> <?xml version="1.0" encoding="utf-8"?>
> <UsersList>
>   <user>
>     <id>100</id>
>     <name>Suresh</name>
>     <password>Kothapally</password>
>   </user>
> </UsersList>

its taken from this link: http://groups.google.com/group/DotNetDevelopment/msg/047978a7a9159e98

Hope it will help you out.


Faraz Shah Khan
MCP, MCAD.Net, MCSD.Net, MCTS-Win/Web, MCPD-Web
Blog
0
farazsk11
8/9/2008 1:03:54 PM
Reply:

Similar Artilces:

Reading a specific node off an XML file, then copying it into a different XML file.
Here's the scenario, I am doing an XML data store of applicants. Once I view the list, which I've done, I want toapprove or deny an entry of my choice. How do I go about approving one node, which, I believe I can specificallyview any one I choose, but then, I want to send the ones I approve to a seperate XML file. Basically, I could doa few things, maybe read the one node I approve to a variable that stores it, then write it to an XML file, I need help. Any would be appreciated on how to do this. How do I go about approving one node?? <APPLICANTLIST>     <APPLIC...

How to get datasource name dynamically from .txt / .xml file using C#.net 2.0 with Mysql 5.0
I am using C#.Net 2.0 With MySql 5.0. I created a project and it works fine in my machine. But problem occurs when i try to run the project other than my machine. I wrote datasource=mysystem name in connection string. Is it possible to get datasource name dynamically from a text file (*.txt) or from .xml file for MySql.Regards,Tamizhselvi  Add an App.Config file to your project and you can drop a connection string in there like so:  <connectionStrings>    <add name="PICK A NAME" connectionString="YOUR CONNECTION STRING"/>...

Sending SMS using vb.net or C#.net using vb.net or c#.net
Hi  My requirement is I hav one csv file with these fields id,mobilenum,messgae,status.intiallu staus is 0. once i read the all fileds and take that mobile number.using tat mobile number  i need to send sms .after sending sms i shuld change status as 1 How to send sms thru coding (please dont provide any links.if it is provide also please give working links becox i checked codeproject .i didnt get any nice link. and also provide the how to update the status field im csv file   Thank ssandhya   To send SMS, you need some third party SMS providers. if you consul...

Problems writing to an XML file
I'm brand new to using XML (in fact this is my first project), so bear with me, I may need a little hand-holding. I'm trying to create a page which simply adds data to an existing xml file. Ultimately it will add the data from a form, but to keep things simple, I've been simply using pre-defined values. Originally I was able to get the script to write the xml exactly as I needed, however it would simply overwrite the existing file every time it was accessed. This is unacceptable, as it will be used to add data to one file, sort of like a mini database. So after much pain and gnashi...

appending to existing xml file using vb.net/c#
hiedoes anyone know how to append a record to an XML file that already exists using vb.net or c#.If i have an xml file like<order date="20/6/2006"><orderID>123</orderID><CustomerID>23</CustomerID><TotalCost>£1200</Totalcost></order>and i want to add another record below this one programmatically.Thanks   Hi, if you se XmlDocument, look for XmlNode.Clone or XmlNode.CloneNode. With these you can make a copy of the node's structure, then you just need to set the values of respective elements and save the XmlDocument.Tha...

How to write a xml file to another computer using path like this \\Server5\XML\XMLTest.xml?
Hi Guys,How can I write a xml file that read from a dataset to another computer in our network?something like this path "\\Server5\XML\XMLTest.xml"I am using below code to write xml file.----------------------------------------            // create a file name to write to.            string filename = "\\Server5\XML\XMLTest.xml";            // create the FileStream to write with.        &nb...

use VB.NET and C#.NET code in the same C#.NET project
All-- Here is a sample that is "off the beaten path", (at least for me). Is it possible, in an ASP.NET application, using the code-behind page building technique, to have both pages written in VB.NET and pages written C#.NET?At http://www.WebLogicArts.com/DemoList.aspx there is a sample that shows that, (contrary to popular belief), it IS possible to mix ASP.NET pages built with C#.NET with ASP.NET pages built with VB.NET in the same VS.NET 2003 project. Note that this is just a "fun" sample to see if it can be done and I do not recommend this practice as a "standard" way of develo...

XML Read issue with specific xml file
Hi Everyone! I wonder if you could help me, I'm desperately struggling to do something in ASP.NET 3.5 (VB) that I had working in Classic ASP. I am reading from various XML files without any trouble at all using code from CodeProject. An example of an XML file that's working correctly is: <family> <name gender="Male"> <firstname>Tom</firstname> <lastname>Smith</lastname> </name> <name gender="Female"> <firstname>Dale</firstname> <lastname>Smith</lastname> <...

write xml file using xml control
Hi Guys, Environment: asp.net 2.0  Lang:vb.net   I am trying to create a xml file using xml control at rumtime. I have a asp:xml control with DocumentSource property set to xml file myFile.xml. myFile.xml: <myRoot>          <EMPLOYEE>               <FNAME></FNAME>               <LNAME></LNAME>         &nbs...

how do i write and read an xml file form C# code file
how can i writing and reading xml file form C# code  Using XmlDocument is the easiest way...see the online help.Steve Wellens My blog Hi, In .NET 3.5 Microsoft introduced new xml classes for in-memory XML programming. This enables us to modify XML documents efficiently and easily. Please find the online help available at the location: http://msdn.microsoft.com/en-us/library/system.xml.linq.aspx...

serialize a XML file to a VB.NET file (class) using xsd
Hello   I would like to serialize  a XML file to a VB.NET  file (class).   How can I use XSD.exe  to generate my xml file  C:\leye_g\Travaux\Fichiers de données\test.xml  to a VB.NET File ?   Best regardsf Hi XML Schema Definition Tool (Xsd.exe)  can generate runtime classes from  XSD files . XmlElementAttribute Is Missing for the Generated Class Members While Using Xsd.exe describes how to generate class from xml and reports a problem. And you could find more info here: Code Generation in the .NET Framework Using XML Sch...

Replace a node from 1 xml file with a node from another xml file
Hi,  suppose i have these 2 xml files: File 1: <resultset morerecords="0" paging-cookie="1">accountid last="{D14D44AD-36D0-DC11-AA32-0003FF33509E}" first="{D14D44AD-36D0-DC11-AA32-0003FF33509E}" /></cookie>"> <result> ... <donotpostalmail name="Allow">0</donotpostalmail> <name>Adventure Works</name> <primarycontactid name="Abhijit Thakur" dsc="0" yomi="Abhijit Thakur">{0820590A-37D0-DC11-AA32-0003FF33509E}</primarycontactid>...

Reading .xml file and executing .xsl over .xml in c#?
I must read http://www.tcmb.gov.tr/kurlar/200705/24052007.xml  and execute .xsl below. And store data into datatable   <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sapxsl="http://www.sap.com/sapxsl" version="1.0">   <xsl:template match="Tarih_Date">     <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">       <asx:values>         <XMLDATAUSE>     &nbs...

Xml serialization of a file in C#.Net
Hi All !Can anyone tell me how to serialize and deserialize a file (specially an image file) in XML using C#.NET ?...

Web resources about - Any good example for write, read a specific node value from a xml file using C#.net - asp.net.xml-datasource

Specific - Wikipedia, the free encyclopedia
Specific Pathogen Free , of a laboratory animal guaranteed free of particular (i.e., specific and named) pathogens "Specific" generally means ...

Specific activity - Wikipedia, the free encyclopedia
... SI quantity related to the phenomenon of natural and artificial radioactivity. The SI unit of "activity" is becquerel, Bq, while that of "specific ...

Facebook Displays Percent Of Users Who Like Pages Who Have Seen Specific Posts
Facebook continues to quietly add and tweak features behind-the-scenes, without fanfare or announcements, and the latest example is the addition ...

Navy Football to Feature Position-Specific 'Navy Fleet' Helmets for Army Game - Bleacher Report
For the first time in NCAA history, a college football team will have its players wearing different helmets during the game based on the position ...

"So the product is being deliberately misused despite a specific warning label, and y'all are complaining ...
"Nobody was irreparably broken or even like stubbed their toe? BURN BUNCH EMS DOWN. Bomb this company back to the stone age before the hair of ...

The FTC has finally given some specific guidance on what native ads are meant to look like
... on a journalism website. The FTC has been exploring how to effectively police native advertising since 2013. On Tuesday it released specific ...

Nashua Public Schools Closed Following ‘Specific’ Threat Of Violence
All public schools in Nashua, NH, will be closed Monday after school officials received a detailed threat of violence involving the city's two ...

Obama: No specific, credible threat indicating plot against U.S.
After a meeting with his national security team, the president tells Americans to "go about their usual Thanksgiving weekend activities"

Tesla Seatbelt Recall Specifics, & Video On How To Check Your Seatbelt Yourself
... of a Model S in Europe with a seatbelt that wasn’t properly attached to the outboard lap pretensioner. [&hellip Tesla Seatbelt Recall Specifics, ...

Obama: No 'specific and credible' holiday threat
CNN Obama: No 'specific and credible' holiday threat CNN Washington (CNN) President Barack Obama insisted Thursday that Americans should feel ...

Resources last updated: 12/29/2015 3:16:35 PM