tags:

views:

93

answers:

4

this seems to be a valid xml file and i was able to import it into dropdownlist, but i don't understand the funny nesting. :

<?xml version="1.0" encoding="utf-8" ?>
<Countries>
  <Country>
    <ID>1</ID>
    <Name>Nepal</Name>
  </Country>
  <Country>
    <ID>2</ID>
    <Name>India</Name>
    <Country>
      <ID>3</ID>
      <Name>China</Name>
    </Country>
    <Country>
      <ID>4</ID>
      <Name>Bhutan</Name>
    </Country>
    <Country>
      <ID>5</ID>
      <Name>USA</Name>
    </Country>
  </Country>
</Countries>

why is there a closing second to last line? what is it closing? and why is india not closed?

+7  A: 

Your file thinks China, Bhutan, and USA are children of India. India is, in fact, closed by the last country end tag. It is technically an "acceptable" (actual term for this is well-formed) XML file, but sanity checks say it makes no sense. File probably should look like this:

<Countries>
<Country>
  <ID>1</ID>
  <Name>Nepal</Name>
</Country>
<Country>
  <ID>2</ID>
  <Name>India</Name>
</Country>
<Country>
  <ID>3</ID>
  <Name>China</Name>
</Country>
<Country>
  <ID>4</ID>
  <Name>Bhutan</Name>
</Country>
<Country>
  <ID>5</ID>
  <Name>USA</Name>
</Country>
</Countries>
Matthew Jones
Indeed, it's well-formed, but would not be valid under a sensible schema. Whether the schema /is/ sensible is unknown.
Matthew Flaschen
Good catch. Updated my answer.
Matthew Jones
A: 

Huh, India is closed with the last /country?

khooler
A: 

Its well formed in theory, but doesnt look well formed to me, by the pattern i see. Most likely just a typo. Or it was generated there is a bug in the code that does the generation.

gmcalab
It is well-formed.
Matthew Flaschen
yes i know it is well formed, that is what i said, read it. i said the patten makes is look weird and makes it not look well formed. thanks for the negative on this, most undeserved.
gmcalab
+1 cause I know what you meant and it was correct.
Matthew Jones
Thank Matthew Jones, most appreciated.
gmcalab
A: 

either validation is turned off or the ELEMENT Country can contain other Country elements. Can you check the DTD for the Country ELEMENT definition?

akf
whats DTD???????
I__
a Document Type Definition, where you can define rules that your document must abide by if your parser is validating. see http://en.wikipedia.org/wiki/Document_Type_Definition
akf