Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Product and Other Certifications and the fly likes whats wrong with this xml Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Certification » Product and Other Certifications
Reply Bookmark "whats wrong with this xml" Watch "whats wrong with this xml" New topic
Author

whats wrong with this xml

Vasim Patel
Ranch Hand

Joined: Apr 29, 2004
Posts: 87
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

Joined: Aug 31, 2004
Posts: 26
</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

Joined: Apr 29, 2004
Posts: 87

</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

Joined: Apr 29, 2004
Posts: 87
I got it.

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

An empty element is represented by <yourElement/> and not </yourElement>
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: whats wrong with this xml
 
Similar Threads
Xml Schema (xsd element/attribute) question
apply- templates!!!!!!!!
XML Signature and canonicalization
CSS with XML
internal parameter entity ?