|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Determine if xml is malformedI 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 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". Show quoteHide quote "Glenn Palomar" <glenn.palo***@autodesk.com> wrote in message news:eGyEw2h%23GHA.4888@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 > > 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. Show quoteHide quote "Scott M." <s-mar@nospam.nospam> wrote in message news:O7BK0Pi%23GHA.4524@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" <glenn.palo***@autodesk.com> wrote in message > news:eGyEw2h%23GHA.4888@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 >> >> > >
Existential question!
vb.net; controls how to check whether a number is an integer? Detecting textchanged event when user initiates it Exception message How to tell if my app is running on laptop or desktop? Simple thread implementation not working. Errors in Page directive How to Reference a .Net Assembly from within VBA? when to use an Interface (the template like thing) in my project? |
|||||||||||||||||||||||