Hi Sam,
An XML file can be many things, but first and foremost it is simply a format
for storing data and objects. You've been looking at it as a format for
storing data. I'd encourage you to look at it as a format for storing
objects... specifically a DataSet object.
You can create a dataset object, add a table for the data you want, and add
the columns for Text and Name like you've described. You can then add the
data rows that you want, sort it, bind it to a databound control, and have
loads of fun, all using tons of documentation online that assumes you've
retrieved the dataset from a database!
Storing it and reading it is called Serializing and Deserializing the
DataSet. (hint: think MSN Search or Google)
Nearly every operation you've described is considered to be 'basic database
operations' and is therefore completely supported with a dataset object.
--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik
Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Sam Collett" <sam.collett@gmail.com> wrote in message
news:1111139609.425845.57920@z14g2000cwz.googlegro ups.com...[color=blue]
> Is there a basic guide on Xml document creation and editing (simpler
> than the MSDN docs). Say I want to create a file containing the
> following:
>
> <?xml version="1.0" encoding="utf-8" standalone="yes"?>
> <Files>
> <File>
> <Text>Test</Text>
> <Name>Test.html</Name>
> </File>
> </Files>
>
> I know how you can use XMLTextWriter to do this:
>
> XmlTextWriter xtw = new XmlTextWriter("myfile.xml",
> System.Text.Encoding.UTF8);
> xtw.WriteStartDocument(true);
> xtw.WriteStartElement("Files");
> xtw.WriteStartElement("File");
> xtw.WriteElementString("Text", txtName.Text);
> xtw.WriteElementString("Name", FileName);
> xtw.WriteEndElement();
> xtw.WriteEndElement();
> xtw.WriteEndDocument();
> xtw.Close();
>
> However, how do you check if the file exists, and append to it instead
> of overwriting?
>
> <?xml version="1.0" encoding="utf-8" standalone="yes"?>
> <Files>
> <File>
> <Text>Test</Text>
> <Name>Test.html</Name>
> </File>
> <File>
> <Text>Test 2</Text>
> <Name>Test2.html</Name>
> </File>
> </Files>
>
> Also, I may wish to delete an existing entry, under certain
> circumstances (file deleted from disk):
>
> <?xml version="1.0" encoding="utf-8" standalone="yes"?>
> <Files>
> <File>
> <Text>Test 2</Text>
> <Name>Test2.html</Name>
> </File>
> </Files>
>
> And also, prevent duplicate entries being added (re uploading a file).
>
> <?xml version="1.0" encoding="utf-8" standalone="yes"?>
> <Files>
> <File>
> <Text>Test</Text>
> <Name>Test.html</Name>
> </File>
> <File>
> <Text>Test 2</Text>
> <Name>Test2.html</Name>
> </File>
> <File>
> <Text>Test</Text>
> <Name>Test.html</Name>
> </File>
> </Files>
>
> I know there is a class library at the code project that writes to XML
> files (
http://www.codeproject.com/csharp/ReadWriteXmlIni.asp), but it
> does far more than I need and I would rather learn how to do it myself
> than rely on a third party library.
>
> I would also like to read the xml from the file and then display in a
> page (links to documents, Text is the link text, Name is the file
> name). Bound to a repeater, also displaying file size by querying the
> file system.
>[/color]