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.

>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. ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.