Skip to main content

Introduction to XML

  • Chapter
  • First Online:
C# and XML Primer
  • 1975 Accesses

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.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

eBook
USD 24.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 34.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Author information

Authors and Affiliations

Authors

Rights and permissions

Reprints 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

Publish with us

Policies and ethics