Is it possible to determine the root element in an XML document using a schema?

Is it possible? I canโ€™t figure out how to do this.

+7
xml xsd
Nov 23 2018-10-11T00:
source share
1 answer

The following should work, I also suggest the W3 Schools section on circuits.

<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> 

It should be an XML structure schema similar to this:

 <rootElement user="Bob"> <child1>Hello</child1> <child1>World</child1> <child2>Optional</child2> </rootElement> 
+5
Nov 23 '10 at 9:03
source share



All Articles