Abstract
So when should you use attributes and when should you use elements? Well, that is largely up to you, but convention usually says that when you have descriptive information, it should go as an attribute. Conversely, information that is part of the data should be an element. In the above examples it makes more sense for us to put the title and author as attributes than it does as children, or elements. This is because those two pieces of information are directly tied to the book. If we were to add chapters to the example, then it would make sense for those chapters to be child elements of the book element.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Author information
Authors and Affiliations
Rights and permissions
Copyright information
© 2017 Jonathan Hartwell
About this chapter
Cite this chapter
Hartwell, J. (2017). Introduction to XML. In: C# and XML Primer. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-2595-0_1
Download citation
DOI: https://doi.org/10.1007/978-1-4842-2595-0_1
Published:
Publisher Name: Apress, Berkeley, CA
Print ISBN: 978-1-4842-2594-3
Online ISBN: 978-1-4842-2595-0
eBook Packages: Professional and Applied ComputingProfessional and Applied Computing (R0)Apress Access Books