tags:

views:

15

answers:

2

hi i have a confusion about xml

please tell me is this valid xml or not. i want to read it using linq to xml

  <registeredPeople>
    <id>1</id>
    <name>mohsan</name>
    <id>2</id>
    <name>ali</name>
    <id>3</id>
    <name>azhar</name>
  </registeredPeople>
A: 

Well, it is well-formed, but it does not make much sense. It should look more like this:

<registeredPeople> 
    <person>
       <id>1</id> 
       <name>mohsan</name> 
    </person>
    <person>
       <id>2</id> 
       <name>ali</name> 
    </person>
    <person>
       <id>3</id> 
       <name>azhar</name> 
    </person>
</registeredPeople> 

or maybe even like this:

<registeredPeople>
    <person id="1" name="mohsan" />
    <person id="2" name="ali" />
    <person id="3" name="azhar" />
</registeredPeople>        
klausbyskov
this one was misleading for me. thanks for clearing
Mohsan
Or like this <registeredPeople><name id="1">mohsan</name>...</registeredPeople>
Obalix
A: 

Nobody can tell if it is valid, but is well-formed.

Tomalak
@Mohsan Wellformed = conforms to the basic rules for writing XML. Valid = it is successfully validated against some DTD or XML Schema.
Obalix