Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
Sheriffs:
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • fred rosenberger
  • Frits Walraven

whats wrong with this xml

 
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
 
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>
 
I wish to win the lottery. I wish for a lovely piece of pie. And I wish for a tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic