KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Important rules for XML ID attributes
PRODUCT: 4D | VERSION: 12 | PLATFORM: Mac & Win
Published On: August 18, 2010

When working with XML documents one way that 4D allows developers to find specific elements in the document is via the ID attribute. The commands DOM Find XML element by ID, SVG Find element ID by coordinates and SVG Find element IDs by rect all find element IDs or elements based on their ID. Other SVG Commands also modify specific elements based on the ID attribute passed to the command.

4D commands use the ID attribute because of the special rules in the XML specification for it. The ID attribute must:

  • Be unique in an XML document

  • Start with colon, letter, or underscore

  • Contain those characters plus dashes, periods, and numbers

  • Only appear once for each element (each element can only have one ID attribute)

Note, there are other more uncommon characters which can be used. For the full list of characters see the XML specification on the ID attribute.

Because the ID element is prevalent in 4D commands and XML in general it is important to keep track of these rules when generating your XML documents.