473,466 Members | 1,391 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Determine if xml is malformed

Hi,

I have an xml file that looks like below. It contains a DOCTYPE declaration
followed by the data itself.

<!DOCTYPE LIB[

<!ELEMENT LIB (TEST?,OS*)>

<!ELEMENT TEST EMPTY>

<!ELEMENT OS (TEST?,SP*)>

<!ELEMENT SP (TEST?,DEVICE*)>

<!ELEMENT DEVICE (TEST?,VERSION*)>

<!ELEMENT VERSION (TEST?)>

<!ATTLIST LIB version CDATA #REQUIRED>

<!ATTLIST LIB date CDATA #REQUIRED>

<!ATTLIST TEST Type CDATA #REQUIRED>

<!ATTLIST TEST Abc CDATA #IMPLIED>

<!ATTLIST TEST Def CDATA #IMPLIED>

<!ATTLIST OS value CDATA #REQUIRED>

<!ATTLIST SP value CDATA #REQUIRED>

<!ATTLIST DEVICE value CDATA #REQUIRED>

<!ATTLIST VERSION value CDATA #REQUIRED>

]>

<LIB version="$Revision: #742 $" date="$DateTime: 2006/10/27 12:50:54 $" >

<OS value="Vista">

</OS>

<OS value="XP">

<TEST Type="ddd" Abc="sdf" Def="123" />

<SP value="SP1">

<DEVICE value="somedevice">

<VERSION value="6.14.10.8888">

<TEST Type="sdf" Abc="sdf0" />

</VERSION</DEVICE</SP</TEST</OS</LIB>

Are there XML .Net classes that I can use to check if the content is
malformed like how VS2205 intellisense works when you manually enter data
into the file.

For example if an attribute is required in a certain node and you don't put
one, is there a way to detect it using .Net classes? Or I have to do the
work by parsing the file and check the content if it follows the DOCTYPE
declaration.

Any help is always appreciated.

Thanks,
Glenn
Oct 27 '06 #1
2 1890
I don't have the class and method call for you, but what you are talking
about is called checking to see if your XML is "valid". I'm not being picky
here because there is also such a thing as "well-formed" xml. When you say
"mal-formed", someone might think you are talking about "well-formed", when
in this case, you are talking about "valid".
"Glenn Palomar" <gl***********@autodesk.comwrote in message
news:eG****************@TK2MSFTNGP04.phx.gbl...
Hi,

I have an xml file that looks like below. It contains a DOCTYPE
declaration followed by the data itself.

<!DOCTYPE LIB[

<!ELEMENT LIB (TEST?,OS*)>

<!ELEMENT TEST EMPTY>

<!ELEMENT OS (TEST?,SP*)>

<!ELEMENT SP (TEST?,DEVICE*)>

<!ELEMENT DEVICE (TEST?,VERSION*)>

<!ELEMENT VERSION (TEST?)>

<!ATTLIST LIB version CDATA #REQUIRED>

<!ATTLIST LIB date CDATA #REQUIRED>

<!ATTLIST TEST Type CDATA #REQUIRED>

<!ATTLIST TEST Abc CDATA #IMPLIED>

<!ATTLIST TEST Def CDATA #IMPLIED>

<!ATTLIST OS value CDATA #REQUIRED>

<!ATTLIST SP value CDATA #REQUIRED>

<!ATTLIST DEVICE value CDATA #REQUIRED>

<!ATTLIST VERSION value CDATA #REQUIRED>

]>

<LIB version="$Revision: #742 $" date="$DateTime: 2006/10/27 12:50:54 $" >

<OS value="Vista">

</OS>

<OS value="XP">

<TEST Type="ddd" Abc="sdf" Def="123" />

<SP value="SP1">

<DEVICE value="somedevice">

<VERSION value="6.14.10.8888">

<TEST Type="sdf" Abc="sdf0" />

</VERSION</DEVICE</SP</TEST</OS</LIB>

Are there XML .Net classes that I can use to check if the content is
malformed like how VS2205 intellisense works when you manually enter data
into the file.

For example if an attribute is required in a certain node and you don't
put one, is there a way to detect it using .Net classes? Or I have to do
the work by parsing the file and check the content if it follows the
DOCTYPE declaration.

Any help is always appreciated.

Thanks,
Glenn


Oct 27 '06 #2
That's correct. I'm really looking at how to easily check if the xml file is
well-formed or valid without parsing and checking it myself.

"Scott M." <s-***@nospam.nospamwrote in message
news:O7****************@TK2MSFTNGP04.phx.gbl...
>I don't have the class and method call for you, but what you are talking
about is called checking to see if your XML is "valid". I'm not being
picky here because there is also such a thing as "well-formed" xml. When
you say "mal-formed", someone might think you are talking about
"well-formed", when in this case, you are talking about "valid".
"Glenn Palomar" <gl***********@autodesk.comwrote in message
news:eG****************@TK2MSFTNGP04.phx.gbl...
>Hi,

I have an xml file that looks like below. It contains a DOCTYPE
declaration followed by the data itself.

<!DOCTYPE LIB[

<!ELEMENT LIB (TEST?,OS*)>

<!ELEMENT TEST EMPTY>

<!ELEMENT OS (TEST?,SP*)>

<!ELEMENT SP (TEST?,DEVICE*)>

<!ELEMENT DEVICE (TEST?,VERSION*)>

<!ELEMENT VERSION (TEST?)>

<!ATTLIST LIB version CDATA #REQUIRED>

<!ATTLIST LIB date CDATA #REQUIRED>

<!ATTLIST TEST Type CDATA #REQUIRED>

<!ATTLIST TEST Abc CDATA #IMPLIED>

<!ATTLIST TEST Def CDATA #IMPLIED>

<!ATTLIST OS value CDATA #REQUIRED>

<!ATTLIST SP value CDATA #REQUIRED>

<!ATTLIST DEVICE value CDATA #REQUIRED>

<!ATTLIST VERSION value CDATA #REQUIRED>

]>

<LIB version="$Revision: #742 $" date="$DateTime: 2006/10/27 12:50:54 $"
> >

<OS value="Vista">

</OS>

<OS value="XP">

<TEST Type="ddd" Abc="sdf" Def="123" />

<SP value="SP1">

<DEVICE value="somedevice">

<VERSION value="6.14.10.8888">

<TEST Type="sdf" Abc="sdf0" />

</VERSION</DEVICE</SP</TEST</OS</LIB>

Are there XML .Net classes that I can use to check if the content is
malformed like how VS2205 intellisense works when you manually enter data
into the file.

For example if an attribute is required in a certain node and you don't
put one, is there a way to detect it using .Net classes? Or I have to do
the work by parsing the file and check the content if it follows the
DOCTYPE declaration.

Any help is always appreciated.

Thanks,
Glenn



Nov 1 '06 #3

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

Similar topics

8
by: KC | last post by:
I have written a parser using htmllib.HTMLParser and it functions fine unless the HTML is malformed. For example, is some instances, the provider of the HTML leaves out the <TR> tags but includes...
1
by: Kiran B. | last post by:
hello, Im getting this error everytime i load this page. malformed header from script. Bad header=*** You don't have the (right): c:/program files/apache group/apache/cgi-bin/fig28_18.py I...
8
by: Magnus Lie Hetland | last post by:
According to The Sgmlop Module Handbook , the handle_entityref() callback is called for "malformed character entities". What does that mean, exactly? What is a malformed character entity? I've...
0
by: Ian A. York | last post by:
MacOS 10.3.8, Python 2.3. I installed both Tkinter and appscript yesterday. Now when I open python (or pythonw) in the Terminal I get the following: Python 2.3 (#1, Sep 13 2003, 00:49:11) on...
0
by: Ryan R. Tharp | last post by:
------=_NextPart_000_08EB_01C34AD3.62428F70 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Using the C API I'm getting this on some of my queries,...
88
by: Mike | last post by:
Is there a way to determine what a user's default email client is? I read a post from 3 years ago that said no. I guess I'm hoping something has come along since then.
3
by: Gérard Talbot | last post by:
About a month ago, I've reported a crash bug at a wiki webpage where developers of MSIE 7 can read feedback from developers. The strange thing is that a particular malformed webpage can crash MSIE...
6
by: sviau | last post by:
http://www.mls.ca/PropertyDetails.aspx?vd=&SearchURL=%3fMode%3d0%26Page%3d1%26vs%3d1%26rlt%3d%26cp%3d%26pt%3d1%26mp%3d0-0-0%26mrt%3d-1-0-0%26Beds%3d0-0%...
1
by: Shalako | last post by:
I check my error log and see these entries: malformed header from script. Bad header= Missing gauge reports are ind: padata.pl /perl/pema/padata.pl did not send an HTTP header malformed...
0
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
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,...
0
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...
1
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...
0
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,...
0
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
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.