Aravind Srinivas
Aravind Srinivas

Reputation: 251

Add attribute without name and value?

Whether XML element attribute name can be empty:

<?xml version="1.0" encoding="utf-8"?>
<test>
  <tables>
    <gg qqq="">
      <ss ""=""/>
      <mm ""=""/>
    </gg>
  </tables>
</test>

I am getting an exception I cant to load this. Is this possible?

Upvotes: 0

Views: 465

Answers (3)

Fendy
Fendy

Reputation: 4643

Short answer, no. If you want to add value but not know what is the name of the value in XML, insert in into the body instead.

<ss>value</ss>

This way, your ss will be treated as a value

Upvotes: 0

Freelancer
Freelancer

Reputation: 9074

No this can not be done.

XML has empty element concept[If you are trying to implement that].

In that whole element is kept empty and said to be null as follow>>

<abc></abc>
<DefaultTaxPrice></DefaultTaxPrice>

Upvotes: 0

abatishchev
abatishchev

Reputation: 100268

No, this will produce invalid XML. Attribute must have both name and value. How do you image opposite?

Upvotes: 1

Related Questions