473,403 Members | 2,222 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

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 1888
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
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...
0
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...

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.