• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

whats wrong with this xml

 
Vasim Patel
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Consider this XML:
1.
<myElement>
</yourElement>
</myElement>

I get an error "The file is not well-formed.myElement closing element name expected."

However if I have yourElement as below it works fine.
2,
<myElement>
<yourElement></yourElement>
</myElement>

Any idea why 1st XML doc is not well formed
 
Sharika Raj
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
</yourElement>
is a closing element.There is no start element, so it is not wellformed.You can use <yourElement> </yourElement> or <yourElement/> if element value is empty.

Vasim are you working in bangalore. I have seen lots of office mails with same name.
 
Vasim Patel
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

</yourElement>
is a closing element.There is no start element, so it is not wellformed.

But isnt it valid to have just </yourElement> signifying empty element.


Vasim are you working in bangalore. I have seen lots of office mails with same name.

Yes I work in Bangalore. Who do you work for?
 
Vasim Patel
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got it.

It should be
<myElement>
<yourElement/>
</myElement>

An empty element is represented by <yourElement/> and not </yourElement>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic