Parsing XMl document

  • Thread starter Thread starter Anthony Boudouvas
  • Start date Start date
A

Anthony Boudouvas

Hi to all,

i have a very simple XML file that i present to a user and i will allow
him/her
to manualy edit it and send it back to a listening server.

What is the best -simple- way to parse it so it does not contain anything
invalid after edit ??
I just need a simple data validation, no xml-schemas etc...

The file is :

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="pSecondsDelay" value="30" />
<add key="pDummy" value="dummy" />
<add key="mDisplayLog" value="sp_DisplayLog" />
</appSettings>
</configuration>

Thanks a lot for any help!


anthonyb
 
Anthony,

You should be able to use the XmlDocument class. It will check that the
documents satisfy the the basic requirement that XML be well-formed. You
should get an exception indicating a parsing error if the document is not
well formed.

Hope this helps.
 
Hi Nicholas,

i mae a code snippet of:
XmlDocument doc = new XmlDocument();

doc.LoadXml(xml);


and indeed it was exactly what i wanted.
I did not new it was so simple, i was in mess with XmlValidateReader,
and XmlPasrerContent and what i wanted was a very basic parsing.

Thanks a lot for your help

anthonybb

Anthony,

You should be able to use the XmlDocument class. It will check that the
documents satisfy the the basic requirement that XML be well-formed. You
should get an exception indicating a parsing error if the document is not
well formed.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
Hi to all,

i have a very simple XML file that i present to a user and i will allow
him/her
to manualy edit it and send it back to a listening server.

What is the best -simple- way to parse it so it does not contain anything
invalid after edit ??
I just need a simple data validation, no xml-schemas etc...

The file is :

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="pSecondsDelay" value="30" />
<add key="pDummy" value="dummy" />
<add key="mDisplayLog" value="sp_DisplayLog" />
</appSettings>
</configuration>

Thanks a lot for any help!


anthonyb
 
Back
Top