473,699 Members | 2,715 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 5036
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
3392
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
1693
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
3953
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
2892
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
2455
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
1606
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
4302
by: randy | last post by:
Can some point me to a good example of parsing XML using C# 2.0? Thanks
3
4379
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
2657
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
8613
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
9172
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8908
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
7745
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
6532
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
4374
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3054
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 we have to send another system
2
2344
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.