Examples of generating XML via com-hfg objects.

The XML classes in the com-hfg library are designed to let you construct or parse xml content in a modular, object-oriented way. The XMLTag class is the base tag for the HTML and SVG classes.

  1. Hello World

Example 1: Hello World

  1. XMLTag tag = new XMLTag("TagOne");
  2. tag.setAttribute("foo", "bar");
  3. tag.addContent("Hello World");
  4. tag.addSubtag(new XMLTag("TagTwo"));
  5.  
  6. System.out.println(tag.toXML());
would produce the following XML snippet:
  1. <TagOne foo='bar'>Hello World<TagTwo /></TagOne>

Return to Main Page