473,748 Members | 6,161 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Parsing XMl document

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" ?>
<configuratio n>
<appSettings>
<add key="pSecondsDe lay" value="30" />
<add key="pDummy" value="dummy" />
<add key="mDisplayLo g" value="sp_Displ ayLog" />
</appSettings>
</configuration>

Thanks a lot for any help!
anthonyb
Nov 15 '05 #1
2 5037
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]
- mv*@spam.guard. caspershouse.co m

"Anthony Boudouvas" <an******@media trel.com> wrote in message
news:ub******** *****@TK2MSFTNG P10.phx.gbl...
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" ?>
<configuratio n>
<appSettings>
<add key="pSecondsDe lay" value="30" />
<add key="pDummy" value="dummy" />
<add key="mDisplayLo g" value="sp_Displ ayLog" />
</appSettings>
</configuration>

Thanks a lot for any help!
anthonyb

Nov 15 '05 #2
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 XmlValidateRead er,
and XmlPasrerConten t 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" ?>
<configuratio n>
<appSettings>
<add key="pSecondsDe lay" value="30" />
<add key="pDummy" value="dummy" />
<add key="mDisplayLo g" value="sp_Displ ayLog" />
</appSettings>
</configuration>

Thanks a lot for any help!
anthonyb


Nov 15 '05 #3

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

Similar topics

2
3395
by: Peter Scott | last post by:
I have a program that listens on an IRC channel and logs everything to XML on standard output. The format of the XML is pretty straightforward, looking like this: <channel name='#sandbox'> <message user='PeterScott'>Hello, my bot</message> <message user='PeterScott'>This is a message</message> <nickchange> <oldnick>PeterScott</oldnick> <newnick>PeterSc</newnick>
0
1694
by: Prakash | last post by:
Hi all, I am trying a parse a xml document containing japanese text by constructing a DOMBuilder object. The document created after parsing is empty. If the xml document does not contain japanese characters, the parsing goes thro' properly. Here is the sample document that is causing the problem. <root>
2
3957
by: Cigdem | last post by:
Hello, I am trying to parse the XML files that the user selects(XML files are on anoher OS400 system called "wkdis3"). But i am permenantly getting that error: Directory0: \\wkdis3\ROOT\home Canonicalpath-Directory4: \\wkdis3\ROOT\home\bwe\ You selected the file named AAA.XML getXmlAlgorithmDocument(): IOException Not logged in
16
2906
by: Terry | last post by:
Hi, This is a newbie's question. I want to preload 4 images and only when all 4 images has been loaded into browser's cache, I want to start a slideshow() function. If images are not completed loaded into cache, the slideshow doesn't look very nice. I am not sure how/when to call the slideshow() function to make sure it starts after the preload has been completed.
4
2459
by: Erik Moore | last post by:
I am both producing and parsing an xml document that needs to be validated against a schema. I wanted some consumers of the document to have the option of not performing a validation, so I left the nodes in the instance unqualified. An example of the document is below: <?xml version="1.0" encoding="utf-8" ?> <filingreceipt xmlns="http://www.disclosureusa.org/filingreceipt.xsd"> <cpofilingnumber>TX2004043037501</cpofilingnumber>...
3
1608
by: David Svoboda | last post by:
I have a server program that takes commands and acts on them. The server program can also take these commands from an input file or standard input (mainly for testing purposes). As such, I often have files full of input commands to feed to the server. Right now the commands that the server takes are well-defined, but not in XML. Since the commands are not self-delimiting, I have to prepend each command with a 'length' number indicating...
5
4305
by: randy | last post by:
Can some point me to a good example of parsing XML using C# 2.0? Thanks
3
4385
by: toton | last post by:
Hi, I have some ascii files, which are having some formatted text. I want to read some section only from the total file. For that what I am doing is indexing the sections (denoted by .START in the file) with the location. And for a particular section I parse only that section. The file is something like, .... DATAS
2
2668
by: nicky123 | last post by:
Hi everyone, This is a brief description that I have provided for parsing & displaying an XML document using DOM API. Please feel free to post your own comments & views regarding this discussion. Thank you. The first step of parsing an XML document is to import the DOM API related classes such as :- java.io.* which contains all the interfaces to perform an I/O operation. org.xml.sax.* which contains all the interfaces...
0
8828
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9367
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9319
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9243
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8241
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6795
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6073
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4869
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2780
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.