Sunday, 15 June 2014

Why use an empty element in XML? -


Route amateur here I get instructions on how to use empty element in XML. But why would you do it? What will be used for this, (I think) to add a blank record other than when the XML is parsed?

Here is information from W3Schools:

"The empty XML element is not any content, it is empty. In XML, you can point to an empty element like this : Code> & lt; element & gt; & lt; / element & gt; or you can use an empty tag like this (the element syntax of this type is called self-termination) <00>

Text "itemprop =" text ">

If a schema is tagged in a tag Isi certainly must exist in order, you may have to include the tag even if the blank value. For example, the following piece from the schema indicates that you should first tag the tag bar:

  & lt; Xs: element name = "parent" & gt; & Lt; XS: complexType & gt; & Lt; XS: Sequence & gt; & Lt; Xs: element name = "foo" min oscurs = "1" maxOccurs = "1" /> & Lt; Xs: element name = "bar" minOccurs = "1" maxOccurs = "1" /> & Lt; / XS: sequence & gt; & Lt; / XS: complexType & gt; & Lt; / XS: element & gt;  

Then the following piece will be valid:

  & lt; Parents & gt; & Lt; Foo / & gt; & Lt; Times> Asdf & lt; / Bars & gt; & Lt; / Parent & gt;  

But the following will not be:

  & lt; Parents & gt; & Lt; Times> Asdf & lt; / Bars & gt; & Lt; / Parent & gt;  

Additionally, you can use an empty tag to represent an empty value (as opposed to a zero value). However, if you are trying to represent zero value in XML then you should actually use a xsi: nil attribute


No comments:

Post a Comment