XOM Sample Code


The nu.xom.samples package contains several dozen example programs showing you how to use various features of XOM. This page organizes the samples by what they demonstrate.

How do I...

1. Parse an existing document?
2. Parse an existing document with a specific parser?
3. Query a document?
4. Create a new document?
5. Create a new document that uses attributes?
6. Create a new document that has a document type declaration?
7. Create a new document that uses namespaces?
8. Store an XML document in a file?
9. Pretty print an XML document?
10. Preserve base URI information when serializing?
11. Modify an XML document?
12. Work with attributes?
13. Move elements from one document to another?
14. Move nodes from one place in a document to another place in the same document?
15. Build a structured XML document from flat, tabular data?
16. Build an XML document from a relational database or other JDBC source?
17. Convert an XML document into a non-XML format?
18. Extend Serializer?
19. Use my own subclasses of the standard XOM classes?
20. Perform an XSL transformation?
21. Resolve all entity references in a document?
22. Process a document in streaming mode?
23. Build a DTD from an instance document?
24. Write a document in Canonical XML?
25. Write a document in a particular character set?
26. Generate a servlet response?
27. Talk to a SOAP service?
28. Talk to an XML-RPC service?
29. Process SOAP requests?
30. Process XML-RPC requests?
31. Find all the comments in an XML document?
32. Read processing instruction data?
33. Validate a document?
34. Validate a document against a schema?
35. Resolve XIncludes?
36. Combine consecutive text nodes?
37. Save memory?
38. Traverse an XML document in preorder?
39. Traverse an XML document in preorder without using recursion?
40. Strip the markup from an element, extracting only its text? content?
41. Traverse an XML document in inorder?
42. Traverse an XML document in postorder?
43. Write a custom NodeFactory?
44. Process a document in streaming mode?
45. Modify/filter a document while parsing?
46. Trim whitespace from a document while parsing?

1.

Parse an existing document?

2.

Parse an existing document with a specific parser?

3.

Query a document?

4.

Create a new document?

5.

Create a new document that uses attributes?

6.

Create a new document that has a document type declaration?

7.

Create a new document that uses namespaces?

8.

Store an XML document in a file?

9.

Pretty print an XML document?

10.

Preserve base URI information when serializing?

11.

Modify an XML document?

12.

Work with attributes?

13.

Move elements from one document to another?

14.

Move nodes from one place in a document to another place in the same document?

15.

Build a structured XML document from flat, tabular data?

16.

Build an XML document from a relational database or other JDBC source?

17.

Convert an XML document into a non-XML format?

18.

Extend Serializer?

19.

Use my own subclasses of the standard XOM classes?

    20.

    Perform an XSL transformation?

    21.

    Resolve all entity references in a document?

    22.

    Process a document in streaming mode?

    23.

    Build a DTD from an instance document?

    24.

    Write a document in Canonical XML?

    25.

    Write a document in a particular character set?

    26.

    Generate a servlet response?

    27.

    Talk to a SOAP service?

    28.

    Talk to an XML-RPC service?

    29.

    Process SOAP requests?

    30.

    Process XML-RPC requests?

    31.

    Find all the comments in an XML document?

    32.

    Read processing instruction data?

    33.

    Validate a document?

    34.

    Validate a document against a schema?

    35.

    Resolve XIncludes?

    36.

    Combine consecutive text nodes?

    37.

    Save memory?

    38.

    Traverse an XML document in preorder?

    39.

    Traverse an XML document in preorder without using recursion?

    40.

    Strip the markup from an element, extracting only its text? content?

    41.

    Traverse an XML document in inorder?

      42.

      Traverse an XML document in postorder?

        43.

        Write a custom NodeFactory?

        44.

        Process a document in streaming mode?

        45.

        Modify/filter a document while parsing?

        46.

        Trim whitespace from a document while parsing?