Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3681588
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:42:17+00:00 2026-05-19T03:42:17+00:00

I had a discussion with a colleague of mine about the XML declaration node

  • 0

I had a discussion with a colleague of mine about the XML declaration node (I’m talking about this => <?xml version="1.0" encoding="UTF-8"?>).

I believe that for something to be called “valid XML”, it requires a XML declaration node.

My colleague states that the XML declaration node is optionnal, since the default encoding is UTF-8 and the version is always 1.0. This make sense, but what does the standard says ?

In short, given the following file:

<books>
  <book id="1"><title>Title</title></book>
</book>

Can we say that:

  1. It is valid XML ?
  2. It is a valid XML node ?
  3. It is a valid XML document ?

Thank you very much.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T03:42:17+00:00Added an answer on May 19, 2026 at 3:42 am

    This:

    <?xml version="1.0" encoding="UTF-8"?>
    

    is not a processing instruction – it is the XML declaration. Its purpose is to configure the XML parser correctly before it starts reading the rest of the document.

    It looks like a processing instruction, but unlike a real processing instruction it will not be part of the DOM the parser creates.

    It is not necessary for “valid” XML. “Valid” means “represents a well-defined document type, as described in a DTD or a schema”. Without a schema or DTD the word “valid” has no meaning.

    Many people mis-use “valid” when they really mean “well-formed”. A well-formed XML document is one that obeys the basic syntax rules of XML.

    There is no XML declaration necessary for a document to be well-formed, either, since there are defaults for both version and encoding (1.0 and UTF-8/UTF-16, respectively). If a Unicode BOM (Byte Order Mark) is present in the file, it determines the encoding. If there is no BOM and no XML declaration, UTF-8 is assumed.

    Here is a canonical thread on how encoding declaration and detection works in XML files. How default is the default encoding (UTF-8) in the XML Declaration?


    To your questions:

    1. It is valid XML ?
      This cannot be answered without a DTD or a schema. It is well-formed, though.
    2. It is a valid XML node ?
      A node is a concept that is related to an in-memory representation of a document (a DOM). This snippet can be parsed into a node, since it is well-formed.
    3. It is a valid XML document ?
      See #1.

    You are confusing a few XML concepts here (not to worry, this confusion is common and stems partly from the fact that the concepts overlap and names are mis-used rather often).

    • It all starts with structured data consisting of names, values and attributes that is organized as a tree.
    • XML means, most basically, a syntax to represent this structured data in textual form (it’s a “Markup Language”). It is what you get when you serialize the tree into a string of characters and it can be used to de-serialize a string of characters into a tree again.
    • Document usually refers to a string of characters that represent a serialized tree. It can be stored in a file, sent over the network or created in-memory.
    • The rules of serialization and de-serialization are very strictly defined. A document (a “string of characters”) that can successfully be de-serialized into a tree is said to be well-formed.
    • The semantics of such a tree (allowed elements, element count and order, namespaces, any number of complex rules, really) can be defined in what is called a DTD or a schema. If a tree obeys a certain set of well-defined semantics, it is said to be valid.
    • The term Document Object Model (DOM) refers to the standardized in-memory representation of structured data. It’s the name of the a well-defined API to access this tree with standardized methods.
    • A node is the basic data structure of a Document Object Model.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I had a discussion this morning with a colleague about static variable initialization order.
I had a discussion with a colleague at work, it was about SQL queries
Today I had a discussion with a colleague about nested functions in Javascript: function
I recently had a discussion with a colleague about serialization of byte data over
I've had a discussion with a colleague about Linq to SQL. I am still
A while ago, I had a discussion with a colleague about how to insert
I friend of mine and I had a discussion a few days back about
We had a discussion with the colleagues about project references and version control systems.
I had a discussion today about refactoring this (#1) public void MyFunc(object myArgument) {
I had a heated discussion with a colleague on the usage of stored procedures

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.