From the course: XML Essential Training

Unlock the full course today

Join today to access over 24,900 courses taught by industry experts.

Declaring complex elements

Declaring complex elements

- [Instructor] If XML were just made up of simple types, then our job would be really easy. But of course, you can define complex tag structures in XML, and we need to weigh in schema to enforce constraints on those. Complex elements are elements that don't just contain basic content like strings or numbers. They can contain other tags or have attributes. So there's two ways to do this. The easy way is to use the anyType for the type attribute in the element tag. So if you define an element and inside the type attribute, you specify anyType, it pretty much means that the content of the element is not restricted in any way. However, you can also use the complex tag type in the definition, and this is the counterpoint to the previous examples in this chapter where we were using the simpleType tag. So let's look at some examples. So how would you declare an empty element using schema? So we have here an empty element, and the way that this works is using the element tag. So to declare…

Contents