0

Hey, I'm attempting to write an XML parser in C++, and I have some questions on some XML syntax. First: what is the rule for what goes between the end of the last attribute and the end of a tag? E.g.:

is this ok: <tag attribute="value" > ?

is this ok: <tag attribute="value"> ?

and this: <tag attribute="value" /> ?

and this: <tag attribute="value"/> ?

Which of those are ok and which are not (if any)?


Second, can there be whitespace between the attribute name and the equal sign and the equal sign and the attribute value: (atr="value", atr = "value",atr ="value", or atr= "value")?

That's it for now, but I might have a couple more questions later.

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by Narue
0

>Which of those are ok and which are not (if any)?
They're all valid XML. The extra space in an empty element is a style guideline in XHTML for compatibility reasons, but that has to do with conforming applications and not the requirements of a parser.

>can there be whitespace between the attribute name and
>the equal sign and the equal sign and the attribute value
I think this will be the least of your problems, but yes, whitespace between markup elements is allowed. The big issue is figuring out where whitespace is significant, and the XML specification will tell you that in painful detail. ;)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.