Escolar Documentos
Profissional Documentos
Cultura Documentos
Agenda
• XML PARSING
• DOM PARSER
• SAX PARSER
Document
Jonathan Gold 228 Merchants RD MA
Element
Text
NamedNodeMap
DOM Interfaces
• Node: Defines properties & methods for all the nodes in DOM tree
• nodeName, nodeType, nodeValue, parentNode
• appendChild(), hasChildNodes(), removeChild();
• Document:
• CreateElement();
• CreateAttribute();
• CreateComment();
• Element: Which represesnts Elements
• getAttribute();
• removeAttribute();
• setAttribute();
• Attr: Provides properties for accessing attribute nodes
• name and value
• Text: Enables to access text nodes.
DOM Interfaces Contd..
• NodeList for ordered lists of nodes
• e.g. getElementsByTagName("name").nodeValue
Output: Jonathan Gold
• Only works with fully formed XML documents: SAX can only
work with a fully formed XML document. It cannot be used to
process partial XML documents.
Disadvantages Contd..
• No random access to the document: Because the document
is not in memory, you must handle data in the order in
which it is processed.
• When you need to abort parsing: Because SAX allows you to abort
processing at any time, you can use it to create applications that fetch
particular data.