Processing Xml With Java - A Guide To Sax, Dom, Jdom, Jaxp, And Trax Free Open Book

Processing Xml With Java - A Guide To Sax, Dom, Jdom, Jaxp, And Trax

Previous Section Next Section

Summary

JDOM models an XML document as a Document object that contains a List of Comment and ProcessingInstruction objects and a single Element object for the root element.

Each Element object contains a List of its children: Comment, ProcessingInstruction, Text, and other Element objects. In addition, it has separate lists of attributes and additional namespaces. The list of children is accessible through the getContent() method. Content can be appended to an element or to a document with the heavily overloaded addContent() method, or removed from the tree using the heavily overloaded removeContent() method. Other mutation operations, such as inserting a node at the beginning or in the middle of an element's children, require using the methods of java.util.List.

With the exception of Namespace, the JDOM core node classes have public constructors, and they are constructed in about the most obvious ways you can imagine. For example, to create a new Attribute object that represents the attribute revision="20020430", you would use the constructor Attribute("revision", "20020430"). Namespaces and local names are always separated in argument lists. Sometimes namespaces are provided as one or two strings containing the namespace URI and the optional prefix. At other times they're provided as a combined Namespace object. (JDOM is not perfectly consistent here.)

All of the core node classes have the getter and setter methods you would expect—for example, setTarget(), getTarget(), setData(), and getData() for ProcessingInstruction; setName(), getName(), setNamespace(), and getNamespace() for Element; and so forth. In addition there are a few common methods that show up across several classes. The detach() method removes a node from its parent. The getParent() method returns a node's parent element. And all of the JDOM nodes provide the usual Java utility methods: equals(), hashCode(), and toString(). Finally, all of these classes implement both Serializable and Cloneable, and all override clone().

    Previous Section Next Section


         Main Menu
    Main Page
    Table of content
    Copyright
    Praise for Elliotte Rusty Harold's 'Processing XML with Java™'
    List of Examples
    List of Figures
    Preface
    Part I: XML
    Part II: SAX
    Part III: DOM
    Part IV: JDOM
    Chapter 14. JDOM
    Chapter 15. The JDOM Model
    The Document Class
    The Element Class
    The Attribute Class
    The Text Class
    The CDATA Class
    The ProcessingInstruction Class
    The Comment Class
    Namespaces
    The DocType Class
    The EntityRef Class
    Summary
    Part V: XPath/XSLT
    Part VI: Appendixes


    More Books
    PHP Hacks
    Processing Xml With Java - A Guide To Sax, Dom, Jdom, Jaxp, And Trax
    The Koran (Holy Qur'an)
    Macromedia Flash 8 Bible
    Search Engine Optimization for Dummies
    YouTube Traffic
    PHP 5 for Dummies
    Harry Potter and The Chamber of Secrets
    Harry Potter and the Sorcerer's Stone
    The Pilgrim's Progress
    Wireless Hacks
    Flash Hacks. 100 Industrial-Strength Tips & Tools
    PayPal Hacks. 100 Industrial-Strength Tips and Tools
    Amazon Hacks
    Pdf Hacks
    The Da Vinci Code
    Google Hacks
    The Holy Bible
    Windows XP For Dummies
    Harry Potter and the Half-Blood Prince
    Seo Book
    Upgrading and Repairing Networks
    Macromedia Dreamweaver 8 UNLEASHED
    Windows XP Annoyances
    Windows XP Hacks
    Microsoft Windows XP Power Toolkit
    Teach Yourself MS Office In 24Hours
    iPod & iTunes Missing Manual
    PC Hacks 100 Industrial-Strength Tips and Tools
    PC Overclocking, Optimization, and Tuning - 2th Edition
    PC Hardware In A Nutshell 3rd Edition
    PC Hardware in a Nutshell, 2nd Edition
    Upgrading and Repairing PCs
    Google for Dummies
    MySQL Cookbook
    Teach Yourself Macromedia Flash 8 In 24 Hours
    PHP CookBook
    Sams Teach Yourself JavaScript in 24 Hours
    PHP5 Manual
    Free Games Paper Airplanes
    500 Juegos Gratis 500 Giochi Gratis 500 Jeux Gratuits 500 Jogos Gratis 500 Kostenlose Spiele