What is the integer value of xvr->NodeType and does it map to any of the
following?
public enum XmlNodeType {
// Summary:
// This is returned by the System.Xml.XmlReader if a Read method has
not been
// called.
None = 0,
//
// Summary:
// An element (for example, <item> ).
Element = 1,
//
// Summary:
// An attribute (for example, id='123' ).
Attribute = 2,
//
// Summary:
// The text content of a node.
Text = 3,
//
// Summary:
// A CDATA section (for example, <![CDATA[my escaped text]]> ).
CDATA = 4,
//
// Summary:
// A reference to an entity (for example, # ).
EntityReference = 5,
//
// Summary:
// An entity declaration (for example, <!ENTITY...> ).
Entity = 6,
//
// Summary:
// A processing instruction (for example, <?pi test?> ).
ProcessingInstruction = 7,
//
// Summary:
// A comment (for example, <!-- my comment --> ).
Comment = 8,
//
// Summary:
// A document object that, as the root of the document tree,
provides access to
// the entire XML document.
Document = 9,
//
// Summary:
// The document type declaration, indicated by the following tag
(for example,
// <!DOCTYPE...> ).
DocumentType = 10,
//
// Summary:
// A document fragment.
DocumentFragment = 11,
//
// Summary:
// A notation in the document type declaration (for example,
<!NOTATION...> ).
Notation = 12,
//
// Summary:
// White space between markup.
Whitespace = 13,
//
// Summary:
// White space between markup in a mixed content model or white
space within
// the xml:space="preserve" scope.
SignificantWhitespace = 14,
//
// Summary:
// An end element tag (for example, </item> ).
EndElement = 15,
//
// Summary:
// Returned when XmlReader gets to the end of the entity replacement
as a
// result of a call to System.Xml.XmlReader.ResolveEntity().
EndEntity = 16,
//
// Summary:
// The XML declaration (for example, <?xml version='1.0'?> ).
XmlDeclaration = 17,
}
[quoted text, click to view] "SHC" <SHC@discussions.microsoft.com> wrote in message
news:B19C50D9-6D07-4928-B8B9-933C55F95B05@microsoft.com...
> Hi all,
> I created an application from the Console Application (.NET) of VC++ .NET
> 2003, and I did "Build" the application of the attached .cpp file,
> volcanoes.xml and geology.dtd on my VC++ .NET 2003 - Windows XP Pro PC
> suscessfully. But when I ran it from the command line - C:\Documents and
> Settings\SHC\My Documents\Visual Studio
> Projects\XMLdtdValidatingReader\Debug>XMLdtdValidatingReader
> valcanoes.xml,
> I got the following message in the console output:
> -> XML declaration
> ** Unknown node type
> -> Comment node, name=, value= Volcano data
> -> Element node, name=geology
> ..................................................
> Please help and tell me why I have "Unknown node type" after XML
> declaration
> and how to correct it.
>
> Thanks in advance,
> SHC
>
> ////-----XmlValidatingReader.cpp----/////
> // This is the main project file for VC++ application project
> // generated using an Application Wizard.
>
> #include "stdafx.h"
>
> #using <mscorlib.dll>
> #using <System.xml.dll>
>
> using namespace System;
> using namespace System::Xml;
> using namespace System::Xml::Schema;
>
> // Validation handler class
> __gc class ValHandler
> {
> public:
> static void ValidationHandler(Object* pSender,
> ValidationEventArgs* pe)
> {
> Console::WriteLine(S"Validation Event: {0}", pe->Message);
> }
> };
>
> int _tmain(int argc, char* argv[])
> {
> // Check for required arguments
> if (argc < 2)
> {
> Console::WriteLine(S"Usage: CppXmlTextReader path");
> return -1;
> }
>
> String* path = new String(argv[1]);
>
> try
> {
> // Create the reader...
> XmlTextReader* rvr = new XmlTextReader("volcanoes.xml");
>
> // Create the validating reader and set the validation type
> XmlValidatingReader* xvr = new XmlValidatingReader(rvr);
> xvr->ValidationType = ValidationType::Auto;
>
> // Set the handler
> xvr->ValidationEventHandler +=
> new ValidationEventHandler(0, &ValHandler::ValidationHandler);
>
> // Read nodes from the XmlValidatingReader
> while (xvr->Read())
> {
> switch (xvr->NodeType)
> {
> case XmlNodeType::XmlDeclaration:
> Console::WriteLine(S"-> XML declaration");
> break;
> case XmlNodeType::Document:
> Console::WriteLine(S"-> Document node");
> break;
> case XmlNodeType::Element:
> Console::WriteLine(S"-> Element node, name={0}", xvr->Name);
> break;
> case XmlNodeType::EndElement:
> Console::WriteLine(S"-> End element node, name={0}",
> xvr->Name);
> break;
> case XmlNodeType::Text:
> Console::WriteLine(S"-> Text node, value={0}", xvr->Value);
> break;
> case XmlNodeType::Comment:
> Console::WriteLine(S"-> Comment node, name={0}, value={1}",
> xvr->Name, xvr->Value);
> break;
> case XmlNodeType::Whitespace:
> break;
> default:
> Console::WriteLine(S"** Unknown node type");
> break;
> }
> }
> }
> catch (Exception* pe)
> {
> Console::WriteLine(pe->ToString());
> }
>
> return 0;
> }
>
> /////----volcanoes.xml----/////
> <?xml version="1.0" ?>
> <!DOCTYPE geology SYSTEM "geology.dtd">
> <!-- Volcano data -->
> <geology>
> <volcano name="Erebus">
> <location>Ross Island, Antarctica</location>
> <height value="3794" unit="m"/>
> <type>stratovolcano</type>
> <eruption>constant activity</eruption>
> <magma>basanite to trachyte</magma>
> </volcano>
> <volcano name="Hekla">
> <location>Iceland</location>
> <type>stratovolcano</type>
> <height value="1491" unit="m"/>
> <eruption>1970</eruption>
> <eruption>1980</eruption>
> <eruption>1991</eruption>
> <magma>calcalkaline</magma>
> <comment>The type is actually intermediate between crater row
> and stratovolcano types</comment>
> </volcano>
> <volcano name="Mauna Loa">
> <location>Hawaii</location>
> <type>shield</type>
> <height value="13677" unit="ft"/>
> <eruption>1984</eruption>
> <magma>basaltic</magma>
> </volcano>
> </geology>
>
> /////---geology.dtd----/////
> <!ELEMENT geology (volcano)+>
> <!ELEMENT volcano (location, height, type, eruption+, magma, comment?>
> <!ELEMENT volcano name CDATA #IMPLIED>
> <!ELEMENT location (#PCDATA)>
> <!ELEMENT height EMPTY>
> <!ELEMENT height value CDATA #IMPLIED