473,498 Members | 1,648 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

delete from XML file

Hi,
I save data from my ASP.NET Application in XML file.How could I delete
elements by <id>THIS_VALUE</id>? Could someone help here? Here it is the
file:

<?xml version="1.0" standalone="yes"?>
<NewDataSet>
<xs:schema id="NewDataSet" xmlns=""
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="NewDataSet" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="logitems">
<xs:complexType>
<xs:sequence>
<xs:element name="id" msdata:AutoIncrement="true"
msdata:AutoIncrementSeed="1" type="xs:int" />
<xs:element name="datetime" type="xs:dateTime" minOccurs="0"
/>
<xs:element name="ip" type="xs:string" minOccurs="0" />
<xs:element name="browser" type="xs:string" minOccurs="0" />
<xs:element name="referer" type="xs:string" minOccurs="0" />
<xs:element name="url" type="xs:string" minOccurs="0" />
<xs:element name="qstring" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:unique name="Constraint1" msdata:PrimaryKey="true">
<xs:selector xpath=".//logitems" />
<xs:field xpath="id" />
</xs:unique>
</xs:element>
</xs:schema>
<logitems>
<id>1</id>
<datetime>2004-09-19T16:28:30.1384896+03:00</datetime>
<ip>127.0.0.1</ip>
<browser>Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR
1.0.3705)</browser>
<referer>none</referer>
<url>/track1.1/WebForm1.aspx</url>
<qstring>none</qstring>
</logitems>
<logitems>
<id>2</id>
<datetime>2004-09-19T16:28:47.8539632+03:00</datetime>
<ip>127.0.0.1</ip>
<browser>Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR
1.0.3705)</browser>
<referer>none</referer>
<url>/track1.1/WebForm1.aspx</url>
<qstring>none</qstring>
</logitems>
<logitems>
<id>3</id>
<datetime>2004-09-19T16:28:59.3504944+03:00</datetime>
<ip>127.0.0.1</ip>
<browser>Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR
1.0.3705)</browser>
<referer>none</referer>
<url>/track1.1/WebForm1.aspx</url>
<qstring>none</qstring>
</logitems>
</NewDataSet>
Thank you in advance!

Viktor
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.760 / Virus Database: 509 - Release Date: 10.9.2004 a.
Nov 16 '05 #1
1 4492
XmlDocument doc = LoadDocument();
int id = "1";
XmlNode node =
doc.DocumentElement.SelectSingleNode(string.Format ("logitems[id='{0}']"
, id.ToString()));
node.ParentNode.RemoveChild(node);

--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"Viktor Popov" <vi****@yahoo.com> wrote in message
news:ua**************@tk2msftngp13.phx.gbl...
Hi,
I save data from my ASP.NET Application in XML file.How could I delete
elements by <id>THIS_VALUE</id>? Could someone help here? Here it is the
file:

<?xml version="1.0" standalone="yes"?>
<NewDataSet>
<xs:schema id="NewDataSet" xmlns=""
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="NewDataSet" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="logitems">
<xs:complexType>
<xs:sequence>
<xs:element name="id" msdata:AutoIncrement="true"
msdata:AutoIncrementSeed="1" type="xs:int" />
<xs:element name="datetime" type="xs:dateTime"
minOccurs="0"
/>
<xs:element name="ip" type="xs:string" minOccurs="0" />
<xs:element name="browser" type="xs:string" minOccurs="0"
/>
<xs:element name="referer" type="xs:string" minOccurs="0"
/>
<xs:element name="url" type="xs:string" minOccurs="0" />
<xs:element name="qstring" type="xs:string" minOccurs="0"
/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:unique name="Constraint1" msdata:PrimaryKey="true">
<xs:selector xpath=".//logitems" />
<xs:field xpath="id" />
</xs:unique>
</xs:element>
</xs:schema>
<logitems>
<id>1</id>
<datetime>2004-09-19T16:28:30.1384896+03:00</datetime>
<ip>127.0.0.1</ip>
<browser>Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR
1.0.3705)</browser>
<referer>none</referer>
<url>/track1.1/WebForm1.aspx</url>
<qstring>none</qstring>
</logitems>
<logitems>
<id>2</id>
<datetime>2004-09-19T16:28:47.8539632+03:00</datetime>
<ip>127.0.0.1</ip>
<browser>Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR
1.0.3705)</browser>
<referer>none</referer>
<url>/track1.1/WebForm1.aspx</url>
<qstring>none</qstring>
</logitems>
<logitems>
<id>3</id>
<datetime>2004-09-19T16:28:59.3504944+03:00</datetime>
<ip>127.0.0.1</ip>
<browser>Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR
1.0.3705)</browser>
<referer>none</referer>
<url>/track1.1/WebForm1.aspx</url>
<qstring>none</qstring>
</logitems>
</NewDataSet>
Thank you in advance!

Viktor
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.760 / Virus Database: 509 - Release Date: 10.9.2004 a.

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
14136
by: Jobs | last post by:
Hello All, I want to delete all files in a directory. I am making a backup copy of all files in the directories say c:\abc by reading and writing to a file. After making a backup copy I want to...
0
2073
by: SeanR | last post by:
I have a function to copare two files. It will first copy the original file form a different server to a local temp path and then compare that version to a version that has been restored form tape....
5
5210
by: | last post by:
Hi all, I've been using C++ for quite a while now and I've come to the point where I need to overload new and delete inorder to track memory and probably some profiling stuff too. I know that...
23
8904
by: da Vinci | last post by:
Greetings, Onwards with the school studying. Working on a program and need to delete a file from a known location on the hard drive but cannot get anything I do to work. I have tried to use...
12
7966
by: Lucas Tam | last post by:
I have a very simple loop: If (Directory.Exists(tempDirectory)) Then Try Dim Files() As String = Directory.GetFiles(tempDirectory) 'Clear out directory For Each Filename As String In Files...
9
8305
by: Paul | last post by:
I'm trying to make get my app to delete all the files in a specified folder and all the files within the folders of the specified folder. e.g. Folder 1 contains three files (File1, File2, File3)...
2
4725
by: createdbyx | last post by:
I am trying to make a file sync utillity to sync files between my laptop and my desktop pc. On my desktop machine (xp pro sp2) I have shared my "Visual Studio Projects" folder using windows simple...
5
38937
by: wo20051223 | last post by:
Deleting some files with C# fails with "Access to the path 'X' is denied". I have files copied from a CD that I burned (and not locked by a process) and a text file that I created in Windows...
3
3265
by: Arpan | last post by:
A Form has a FileUpload, 2 Buttons & a TextBox web server controls. Using the FileUpload control, I want to give users the provision to move & delete files that DO NOT exist in C:\Inetpub\wwwroot...
7
4211
by: Anil Gupte | last post by:
Private Sub mnu2Exit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu2Exit.Click Dim fDir As String = Path.GetDirectoryName(L3Global.VideoFileName) ...
0
7126
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7005
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7168
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6891
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
4916
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4595
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3087
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1424
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
659
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.