M-Exam Flashcards
An XML element can contain?
- text
- attributes
- other elements
XML Naming Rules
- Element names are case-sensitive
- Element names must start with a letter or underscore
- Element names cannot start with the letters xml (or XML, or Xml, etc)
- Element names can contain letters, digits, hyphens, underscores, and periods
- Element names cannot contain spaces
Best XML Naming Practices
Create descriptive names, like this: <person>, <firstname>, <lastname>.</lastname></firstname></person>
Best XML Naming Practices
Create short and simple names, like this: <book_title> not like this: <the_title_of_the_book>.</the_title_of_the_book></book_title>
Best XML Naming Practices
Avoid “-“. If you name something “first-name”, some software may think you want to subtract “name” from “first”.
Best XML Naming Practices
Avoid “.”. If you name something “first.name”, some software may think that “name” is a property of the object “first”.
Best XML Naming Practices
Avoid “:”. Colons are reserved for namespaces (more later).
Best XML Naming Practices
Non-English letters like éòá are perfectly legal in XML, but watch out for problems if your software doesn’t support them!
Naming Conversion Tip
Choose your naming style, and be consistent about it!
XML documents often have a corresponding database. A common practice is to use the naming rules of the database for the XML elements.
XML Attributes
Attribute values must always be quoted. Either single or double quotes can be used.
Things to consider when using attributes
- attributes cannot contain multiple values (elements can)
- attributes cannot contain tree structures (elements can)
- attributes are not easily expandable (for future changes)
provide a method to avoid element name conflicts.
XML Namespace
Displaying XML
Raw XML files can be viewed in all major browsers.
Don’t expect XML files to be displayed as HTML pages
object can be used to request data from a web server.
XMLHTTPRequest
defines the properties and methods for accessing and editing XML.
XML DOM (Document Object Model)
All modern browsers have a built-in _______ that can convert text into an XML DOM object.
XML Parser
defines a standard for accessing and manipulating documents.
XML DOM
defines a standard way for accessing and manipulating HTML documents. It presents an HTML document as a tree-structure.
HTML DOM
defines a standard way for accessing and manipulating XML documents. It presents an XML document as a tree-structure.
XML DOM
a major element in the XSLT standard.
XPath
can be used to navigate through elements and attributes in an XML document.
XPath
selects the first book element that is the child of the bookstore element.
/bookstore/book[1]
selects the last book element that is the child of the bookstore element.
/bookstore/book[last()]
selects the last but one book element that is the child of the bookstore element.
/bookstore/book[last()-1]