Is this possible? I can't work out how to do it.
The root element defines the first element of the XML document and defines a reference to the root complexType. The root complexType is the complexType from which all other complexTypes are related to in their ancestry, whether the root is the parent, grand parent, great grand parent, etc.
The XML document above consists of a root element, "shiporder", that contains a required attribute called "orderid".
The XML schema defines the shape, or structure, of an XML document, along with rules for data content and semantics such as what fields an element can contain, which sub elements it can contain and how many items can be present.
Android "Valid XML document must have a root tag at line"
The following should work, I'd also suggest the W3 Schools section on schemas.
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="rootElement" type="RootElementType"/>
<xs:complexType name="RootElementType">
<xs:sequence>
<xs:element name="child1" type="xs:string" minOccurs="1" maxOccurs="unbounded"/>
<xs:element name="child2" type="xs:string" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
<xs:attribute name="user" type="xs:string" use="required"/>
</xs:complexType>
</xs:schema>
This should be the schema for an XML structure like this:
<rootElement user="Bob">
<child1>Hello</child1>
<child1>World</child1>
<child2>Optional</child2>
</rootElement>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With