473,387 Members | 1,760 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Empty elements (Xml)

Hello!

I can't see any point of having empy elements in Xml such as

<Car />
or
<Car></Car>

The two above have identical meaning which is that the Car element is an
empy element.

Can somebody explain the reson for having empty elements in Xml ?

/Tony
Aug 14 '08 #1
2 2044
Tony Johansson <jo*****************@telia.comwrote:
I can't see any point of having empy elements in Xml such as

<Car />
or
<Car></Car>

The two above have identical meaning which is that the Car element is an
empy element.

Can somebody explain the reson for having empty elements in Xml ?
Do you mean you can't see any reason in using the second form instead
of the first, or you can't see any reason for having them at all?

If you're asking the second question, consider tags like <br /and
<hr /in HTML - just the presence of an element can have meaning,
without any extra data.

--
Jon Skeet - <sk***@pobox.com>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon.skeet
C# in Depth: http://csharpindepth.com
Aug 14 '08 #2
Tony Johansson wrote:
I can't see any point of having empy elements in Xml such as

<Car />
or
<Car></Car>

The two above have identical meaning which is that the Car element is an
empy element.

Can somebody explain the reson for having empty elements in Xml ?
Tag not present and empty tag is different.

Analogy: in a database for a VARCHAR column then NULL and ''
are also different. You can somewhat consider tag not present
to be NULL and empty tag to be ''.

I don't know if it is a good analogy, but you can most certainly
test for tag not present versus empty tag in XML processing code.

Arne
Aug 15 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Mikko Ohtamaa | last post by:
From XML specification: The representation of an empty element is either a start-tag immediately followed by an end-tag, or an empty-element tag. (This means that <foo></foo> is equal to...
3
by: Lukas | last post by:
title: xml to xml mapping: empty elements output although input element is not empty Why is is that when mapping from a XML schema to another XML schema, when drawing a default connection...
4
by: T Conti | last post by:
Howdy: I am currently writing a .Net handler to replace an ASP page. The ASP module used a COM dll to format XML. This dll was pretty robust and it auto-suppressed empty elements and...
2
by: Andreas Palm | last post by:
I have a dataset that has DBNull in certain columns, now when I write out this one to XML, I only get the columns as elements that do have data in it. However I do need also the empty colums as...
6
by: Pavils Jurjans | last post by:
Hello, Here's the sample XML: <sample1></sample1> <sample2/> From many XML books and online documentations, it is said to be just different syntax for the same data. However, when we...
3
by: Clark Spencer | last post by:
I have built a small integration app using VS .NET 2003 that extracts orderinformation from a 'webshop'. Extracting the orderinformation works fine. Appending the order elements in the...
7
by: kumar.senthil | last post by:
Hi, I'm using XmlSerializer to create an object from the XML string. I would like to know whether I can get a null value for an empty XML element. Actually the XmlSerializer assigns "" (empty...
1
by: DrDavey | last post by:
What are the advantages/disadvantages of using a choice of a several "sub-"elements with empty content (and no attributes) vs. simple content. Here's an example: Using simple content:...
3
by: August Karlstrom | last post by:
Hi everyone, In XHTML, can any empty element <foo></foobe replaced by <foo />? Example: <table> <tr><td>1</td><td>2</td></tr> <tr><td /><td>4</td></tr> </table>
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.