Re: Unable to read the XML declaration

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Martin Honnen (mahotrash_at_yahoo.de)
Date: 10/22/04


Date: Fri, 22 Oct 2004 15:39:32 +0200


The Kiddie wrote:

> I am reading a XML document and parsing it into a listbox. I'm juat
> learning XML and i can't find a way to read the Xml declaration
> <?xml version="1.0" encoding="utf-8"?>
> In the debugger I can see that there is a declaration element to the
> XMLDocument, but this not recognised by the compiler. I can get it
> through the parsing the InnerText but surely there is a better way to
> get it than that.

Are you writing your own XML parser or are you using one of the .NET
classes (XmlTextReader, XmlDocument/DOM, XPathDocument)?
XmlTextReader exposes the Encoding, and DOM (in .NET) models the XML
declaration as a node of type XmlDeclaration which has properties
Encoding, Standalone and Version.

-- 
	Martin Honnen
	http://JavaScript.FAQTs.com/


Relevant Pages

  • Re: what does "serialization" mean?
    ... I didn't notice that the first time around. ... message about how the declaration itself is already in the desired ... encoding, so the parser has to try it various ways to see what it ... So I went back to the chapter on XML in that book ("Visual Basic .NET, ...
    (comp.programming)
  • Re: ANC: tmlrss.tcl - process RSS newsfeeds for tclhttpd
    ... make sure it generates *legal* HTML such as ... ... When one gets the feed, which is in XML, over HTTP, encodings are sometimes done ... As TDOM's Expat parser reads the XML declaration, ... So that leaves me to do [encoding ...
    (comp.lang.tcl)
  • Re: UTF-8 encoding problem
    ... Declaration having the "encoding" attribute at the begining of file ... What I am saying is the "encoding" of your physical file is different then the logical file (the xml itself). ... It sounds like your physical file is UTF-8, while I'm concerned your logical file is whatever, where whatever is the text you blindly copied from an MSDN article. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Validation: HTML5 vs. XHTML5
    ... Posting with such a From header field value is widely considered rude (see ... The message body of your posting was not. ... An XML document needs a proper DOCTYPE ... An XML document without a standalone declaration and at least a public ...
    (comp.infosystems.www.authoring.html)
  • Re: TCL Dom question
    ... > I'm haven't actually used TclDOM yet, but I'm glad to hear that. ... One reason why I like XML so much, ... >>declares the character encoding used in the XML Declaration, ...
    (comp.lang.tcl)