home
NEWS       BLOGS       FORUMS       NEWSLETTERS       RESEARCH       EVENTS       DIGITAL LIBRARY       CAREERS  
Network Computing Network Computing Powered by InformationWeek Business Technology Network

IMMERSE YOURSELF:

SOA

  |

Data Center

  |

802.11n

  |

Data Privacy

  |
APO  |

Virtualization

  |

NAC

  |

Security

  |

Network Mgmt

  |

Enterprise Apps

  |

Storage & Servers



Netdesign Manual

Part 2

Java XML Programmers Reference

Chapter 11: XML Tools for Information Appliances


September 24, 2001


Brought to you by:





Check It Out!

Package nanoxml

This is the only package in the NanoXML library. This version has only two classes: XMLElement and XMLParseException. XMLElement represents an XML document and its content. XMLParseException is the exception that is thrown when a parse error occurs; for example, when a document that is not well-formed is encountered. Let's look at each of these classes in detail.

Class XMLElement
nanoxml

public class XMLElement

XMLElement is a representation of an XML document. In addition to being able to parse XML documents, this serializable class contains all the methods needed to get/set elements, subelements, attributes, and text in a document. It derives from java.lang.Object.

Constructors

public XMLElement()
public XMLElement(Properties conversionTable)
public XMLElement(boolean skipLeadingWhitespace)
public XMLElement(Properties conversionTable, 
boolean skipLeadingWhitespace)
public XMLElement(Properties conversionTable, 
boolean skipLeadingWhitespace, 
boolean ignoreCase)
Arguments

The XMLElement constructor can only take a few different arguments. Each constructor makes use of a conversion table. A conversion table is simply a Properties object, which is used to map entities to their conversion values. When an entity is found in a parsed document, it is used as a key into the Properties object to find the replacement value.

The default constructor creates a new XMLElement object with a Properties map that converts the following predefined entities:



Here is a summary of the constructor arguments:

Arguments Type Effect
conversionTable java.util.Properties Entities are keys into the Properties map that provide a replacement value when the key is found in during parsing
SkipLeadingWhitespace boolean Directs the parser to ignore leading whitespace in #PCDATA
ignoreCase boolean Directs the parser to ignore element and attribute case. Useful for HTML parsing.
If a conversion table is specified, the base entities specified above (& < > ' ") are used in addition to that table. The default values for the other two arguments are false for skipLeadingWhitespace (whitespace won't be skipped), and notice that the default argument is true for ignoreCase.

Parse Methods

The parse() methods direct an XMLElement object to begin parsing an XML document.

public void parseString (String string) 
throws XMLParseException
public int parseString (String string, int offset)
throws XMLParseException
public int parseString (String string, int offset, int end) 
throws XMLParseException
public int parseString (String string, int offset, 
int end, int startingLineNr)
throws XMLParseException
public void parseFromReader(java.io.Reader reader) 
throws IOException, XMLParseException
public void parseFromReader(java.io.Reader reader, int startingLineNr) 
throws IOException, XMLParseException
public int parseCharArray (char[]chrAry, int offset, int end)
throws XMLParseException
public int parseCharArray(char[] chrAry, int offset, int end, 
int startingLineNr) 
throws XMLParseException
The parseString() and parseFromReader() methods actually just resolve to one of the parseFromCharArray() method calls.

Arguments Type Effect
string String XML source content is contained within a string
reader java.io. Reader XML source content is contained within a java.io.Reader
chrAry char[] XML source content is contained within a character array
offset int Marks where parsing should begin, counting from the first character
End int Marks where parsing should end
startingLineNr int Marks from which line the parser should begin parsing
Usage and Examples

To direct NanoXML to parse an XML file, we would write code like this:

BufferedReader br = null;
try {
br = new BufferedReader(new
FileReader("request.xml"));
}
catch (java.io.FileNotFoundException e) {
e.printStackTrace();
System.exit(0);
}
XMLElement elem = new XMLElement();
try {
elem.parseFromReader(br);
}
catch (java.io.IOException e) { 
e.printStackTrace();
}


PAGE: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | NEXT PAGE
 





Ready to take that job and shove it?

Function:

Keyword(s):

State:
SPONSOR
RECENT JOB POSTINGS
CAREER NEWS
Go beyond Google and get vertical. These specialized search sites will help you find the business information you need -- fast.

Ari Balogh was named to the post of chief technology officer as the companys for a "realignment" of employees.










InformationWeek U.S. IT Salary Survey 2008
Salaries for business technology professionals are falling. Here's what you need to know in order to make good hiring decisions and personal career choices. Download Today
 
ROLLING RIGHT ALONG
Follow key Network Computing Reviews from conception to completion. This Week: Holistic APM.



Network Computing Reports Emerging Enterprise Podcast Series: Secrets to Success








TechSearch


Microsite of the Week


Powerful Information at Your Fingertips



InformationWeek Business Technology Network
InformationWeekInformationWeek 500InformationWeek 500 ConferenceInformationWeek AnalyticsInformationWeek CIO
InformationWeek EventsInformationWeek ReportsInformationWeek MagazinebMightyByte and SwitchDark Reading
Digital LibraryIntelligent EnterpriseInternet EvolutionNetwork ComputingNo JitterPlug Into The Cloud
space
Techweb Events Network
InteropVoiceConWeb 2.0 ExpoWeb 2.0 SummitEnterprise 2.0 ConferenceMobile Business ExpoSoftware ConferenceCSI - Computer Security Institute
Black HatGTECEnergy CampMashup CampStartup Camp
space
Light Reading Communications Network
Light ReadingLight Reading EuropeUnstrungLight Reading's Cable Digital NewsConstantinopleInternet EvolutionPyramid Research
Heavy ReadingLight Reading Live!Light Reading InsiderEthernet ExpoOptical ExpoTeleco TVTower Technology Summit
space
Financial Technology Network
Advanced TradingBank Systems & TechnologyInsurance & TechnologyWall Street & TechnologyAccelerating Wall StreetBank Systems & Technology Executive SummitBuyside Trading SummitInsurance & Technology Executive Summit
space
Microsoft Technology Network
MSDN MagazineTechNetThe Architecture Journal
space


App Infrastructure   |   Messaging & Collaboration   |   Network & Systems Mgmt   |   Network Infrastructure   |   Security  |   Storage & Servers   |   Wireless   |   Enterprise Apps
About Us  |  Contact Us  |  Site Map  |  Technology Marketing Solutions  |  Advertising Contacts  |   Briefing Centers
Copyright © 2008  United Business Media LLC  |  Privacy Statement  |  Terms of Service  |  Your California Privacy Rights