IBM Support

XML Syntax Rules

Question & Answer


Question

XML Syntax Rules

Answer

XML Syntax Rules

You mustfollow these rules when you create XML syntax:

  • All XML elements must have a closing tag.
  • XML tags are case sensitive.
  • All XML elements must be properly nested.
  • All XML documents must have a root element.
  • Attribute values must always be quoted.

All XML elements must have a closing tag

Itis illegal to omit the closing tag when you are creating XML syntax.XML elements must have a closing tag.

Incorrect:

<body>See Spot run.<body>See Spot catch the ball.

Correct:

<body>See Spot run.</body><body>See Spot catch the ball.</body>

XML tags are case sensitive

When you createXML documents the tag <Body> is different from the tag <body>.

Incorrect:

<Body>See Spot run.</body>

Correct:

<body>See Spot run.</body>

All XML elements must be properly nested

Impropernesting of tags makes no sense to XML.

Incorrect:

<b><i>This text is bold and italic.</b></i>

Correct:

<b><i>This text is bold and italic.</i></b>

All XML documents must have a root element

AllXML documents must contain a single tag pair to define a root element.All other elements must be within this root element. All elementscan have sub elements (child elements). Sub elements must be correctlynested within their parent element.

Example:

<root>??<child>????<subchild>.....</subchild>??</child></root>

Attribute values must always be quoted

Itis illegal to omit quotation marks around attribute values. XML elementscan have attributes in name/value pairs; however the attribute valuemust always be quoted.

Incorrect:

<?xml version= ?1.0? encoding=?ISO-8859-1??><note date=05/05/05><to>Dick</to><from>Jane</from></note>

Correct:

<?xml version= ?1.0? encoding=?ISO-8859-1??><note date=?05/05/05?><to>Dick</to><from>Jane</from></note>

In the incorrect document the date attributein the note element is not quoted.

"

[{"Business Unit":{"code":"BU055","label":"Cognitive Applications"},"Product":{"code":"SS73G6","label":"Sterling Total Payments for Financial Services"},"Component":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"All Versions","Edition":"","Line of Business":{"code":"","label":""}}]

Document Information

Modified date:
08 December 2018

UID

ibm10758453