本文整理汇总了Java中com.lowagie.text.xml.simpleparser.SimpleXMLParser类的典型用法代码示例。如果您正苦于以下问题:Java SimpleXMLParser类的具体用法?Java SimpleXMLParser怎么用?Java SimpleXMLParser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SimpleXMLParser类属于com.lowagie.text.xml.simpleparser包,在下文中一共展示了SimpleXMLParser类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: exportToXML
import com.lowagie.text.xml.simpleparser.SimpleXMLParser; //导入依赖的package包/类
/**
* Exports the destinations to XML.
* @param names the names
* @param wrt the export destination. The writer is not closed
* @param encoding the encoding according to IANA conventions
* @param onlyASCII codes above 127 will always be escaped with &#nn; if <CODE>true</CODE>,
* whatever the encoding
* @throws IOException on error
*/
public static void exportToXML(HashMap names, Writer wrt, String encoding, boolean onlyASCII) throws IOException {
wrt.write("<?xml version=\"1.0\" encoding=\"");
wrt.write(SimpleXMLParser.escapeXML(encoding, onlyASCII));
wrt.write("\"?>\n<Destination>\n");
for (Iterator it = names.entrySet().iterator(); it.hasNext();) {
Map.Entry entry = (Map.Entry)it.next();
String key = (String)entry.getKey();
String value = (String)entry.getValue();
wrt.write(" <Name Page=\"");
wrt.write(SimpleXMLParser.escapeXML(value, onlyASCII));
wrt.write("\">");
wrt.write(SimpleXMLParser.escapeXML(escapeBinaryString(key), onlyASCII));
wrt.write("</Name>\n");
}
wrt.write("</Destination>\n");
wrt.flush();
}
示例2: XfdfReader
import com.lowagie.text.xml.simpleparser.SimpleXMLParser; //导入依赖的package包/类
/** Reads an XFDF form.
* @param filename the file name of the form
* @throws IOException on error
*/
public XfdfReader(String filename) throws IOException {
FileInputStream fin = null;
try {
fin = new FileInputStream(filename);
SimpleXMLParser.parse(this, fin);
}
finally {
try{if (fin != null) {fin.close();}}catch(Exception e){}
}
}
示例3: exportToXMLNode
import com.lowagie.text.xml.simpleparser.SimpleXMLParser; //导入依赖的package包/类
/**
* Exports the bookmarks to XML. Only of use if the generation is to be include in
* some other XML document.
* @param list the bookmarks
* @param out the export destination. The writer is not closed
* @param indent the indentation level. Pretty printing significant only
* @param onlyASCII codes above 127 will always be escaped with &#nn; if <CODE>true</CODE>,
* whatever the encoding
* @throws IOException on error
*/
public static void exportToXMLNode(List list, Writer out, int indent, boolean onlyASCII) throws IOException {
StringBuilder dep = new StringBuilder(8);
for (int k = 0; k < indent; ++k) {
dep.append(" ");
}
for (Iterator it = list.iterator(); it.hasNext();) {
HashMap map = (HashMap)it.next();
String title = null;
out.write(dep.toString());
out.write("<Title ");
List kids = null;
for (Iterator e = map.entrySet().iterator(); e.hasNext();) {
Map.Entry entry = (Map.Entry) e.next();
String key = (String) entry.getKey();
if (key.equals("Title")) {
title = (String) entry.getValue();
continue;
}
else if (key.equals("Kids")) {
kids = (List) entry.getValue();
continue;
}
else {
out.write(key);
out.write("=\"");
String value = (String) entry.getValue();
if (key.equals("Named") || key.equals("NamedN")) {
value = SimpleNamedDestination.escapeBinaryString(value);
}
out.write(SimpleXMLParser.escapeXML(value, onlyASCII));
out.write("\" ");
}
}
out.write(">");
if (title == null) {
title = "";
}
out.write(SimpleXMLParser.escapeXML(title, onlyASCII));
if (kids != null) {
out.write("\n");
exportToXMLNode(kids, out, indent + 1, onlyASCII);
out.write(dep.toString());
}
out.write("</Title>\n");
}
}
示例4: parse
import com.lowagie.text.xml.simpleparser.SimpleXMLParser; //导入依赖的package包/类
public void parse(Reader reader) throws IOException {
SimpleXMLParser.parse(this, null, reader, true);
}
示例5: exportToXMLNode
import com.lowagie.text.xml.simpleparser.SimpleXMLParser; //导入依赖的package包/类
/**
* Exports the bookmarks to XML. Only of use if the generation is to be include in
* some other XML document.
* @param list the bookmarks
* @param out the export destination. The writer is not closed
* @param indent the indentation level. Pretty printing significant only
* @param onlyASCII codes above 127 will always be escaped with &#nn; if <CODE>true</CODE>,
* whatever the encoding
* @throws IOException on error
*/
public static void exportToXMLNode(List list, Writer out, int indent, boolean onlyASCII) throws IOException {
String dep = "";
for (int k = 0; k < indent; ++k)
dep += " ";
for (Iterator it = list.iterator(); it.hasNext();) {
HashMap map = (HashMap)it.next();
String title = null;
out.write(dep);
out.write("<Title ");
List kids = null;
for (Iterator e = map.entrySet().iterator(); e.hasNext();) {
Map.Entry entry = (Map.Entry) e.next();
String key = (String) entry.getKey();
if (key.equals("Title")) {
title = (String) entry.getValue();
continue;
}
else if (key.equals("Kids")) {
kids = (List) entry.getValue();
continue;
}
else {
out.write(key);
out.write("=\"");
String value = (String) entry.getValue();
if (key.equals("Named") || key.equals("NamedN"))
value = SimpleNamedDestination.escapeBinaryString(value);
out.write(SimpleXMLParser.escapeXML(value, onlyASCII));
out.write("\" ");
}
}
out.write(">");
if (title == null)
title = "";
out.write(SimpleXMLParser.escapeXML(title, onlyASCII));
if (kids != null) {
out.write("\n");
exportToXMLNode(kids, out, indent + 1, onlyASCII);
out.write(dep);
}
out.write("</Title>\n");
}
}
示例6: exportToXML
import com.lowagie.text.xml.simpleparser.SimpleXMLParser; //导入依赖的package包/类
/**
* Exports the bookmarks to XML.
* @param list the bookmarks
* @param wrt the export destination. The writer is not closed
* @param encoding the encoding according to IANA conventions
* @param onlyASCII codes above 127 will always be escaped with &#nn; if <CODE>true</CODE>,
* whatever the encoding
* @throws IOException on error
*/
public static void exportToXML(List list, Writer wrt, String encoding, boolean onlyASCII) throws IOException {
wrt.write("<?xml version=\"1.0\" encoding=\"");
wrt.write(SimpleXMLParser.escapeXML(encoding, onlyASCII));
wrt.write("\"?>\n<Bookmark>\n");
exportToXMLNode(list, wrt, 1, onlyASCII);
wrt.write("</Bookmark>\n");
wrt.flush();
}
示例7: importFromXML
import com.lowagie.text.xml.simpleparser.SimpleXMLParser; //导入依赖的package包/类
/**
* Import the names from XML.
* @param in the XML source. The stream is not closed
* @throws IOException on error
* @return the names
*/
public static HashMap importFromXML(InputStream in) throws IOException {
SimpleNamedDestination names = new SimpleNamedDestination();
SimpleXMLParser.parse(names, in);
return names.xmlNames;
}
示例8: importFromXML
import com.lowagie.text.xml.simpleparser.SimpleXMLParser; //导入依赖的package包/类
/**
* Import the bookmarks from XML.
* @param in the XML source. The stream is not closed
* @throws IOException on error
* @return the bookmarks
*/
public static List importFromXML(InputStream in) throws IOException {
SimpleBookmark book = new SimpleBookmark();
SimpleXMLParser.parse(book, in);
return book.topList;
}