Adding a schema reference
If you work with XML, you should also work with XML Schema. The XML Schema specifies the layout of the XML document. It can also be used to specify data types for content embedded in the document. XML Schemas make working with XML more predictable, since it is possible to validate XML against it and perform certain processes automatically. XML Schemas separate elements and their attributes using namespaces. These are typically URLs. In XML, the namespace of an element and its children are defined by using the xmlns attribute. Typically, for short XML responses, we only need to set it on the root element. In our case, we will use a local schema and define the namespace to be the URL of the sensor itself, with /schema.xsd ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access