Package com.itextpdf.text.xml
Class XmlToTxt
- java.lang.Object
-
- com.itextpdf.text.xml.XmlToTxt
-
- All Implemented Interfaces:
SimpleXMLDocHandler
public class XmlToTxt extends java.lang.Object implements SimpleXMLDocHandler
This class converts XML into plain text stripping all tags.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.StringBuffer
buf
Buffer that stores all content that is encountered.
-
Constructor Summary
Constructors Modifier Constructor Description protected
XmlToTxt()
Creates an instance of XML to TXT.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
endDocument()
Called after the document is parsed.void
endElement(java.lang.String tag)
Called when an end tag is found.static java.lang.String
parse(java.io.InputStream is)
Static method that parses an XML InputStream.void
startDocument()
Called when the document starts to be parsed.void
startElement(java.lang.String tag, java.util.Map<java.lang.String,java.lang.String> h)
Called when a start tag is found.void
text(java.lang.String str)
Called when a text element is found.java.lang.String
toString()
-
-
-
Method Detail
-
parse
public static java.lang.String parse(java.io.InputStream is) throws java.io.IOException
Static method that parses an XML InputStream.- Parameters:
is
- the XML input that needs to be parsed- Returns:
- a String obtained by removing all tags from the XML
- Throws:
java.io.IOException
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
- Returns:
- the String after parsing.
-
startElement
public void startElement(java.lang.String tag, java.util.Map<java.lang.String,java.lang.String> h)
Description copied from interface:SimpleXMLDocHandler
Called when a start tag is found.- Specified by:
startElement
in interfaceSimpleXMLDocHandler
- Parameters:
tag
- the tag nameh
- the tag's attributes- See Also:
SimpleXMLDocHandler.startElement(java.lang.String, java.util.Map)
-
endElement
public void endElement(java.lang.String tag)
Description copied from interface:SimpleXMLDocHandler
Called when an end tag is found.- Specified by:
endElement
in interfaceSimpleXMLDocHandler
- Parameters:
tag
- the tag name- See Also:
SimpleXMLDocHandler.endElement(java.lang.String)
-
startDocument
public void startDocument()
Description copied from interface:SimpleXMLDocHandler
Called when the document starts to be parsed.- Specified by:
startDocument
in interfaceSimpleXMLDocHandler
- See Also:
SimpleXMLDocHandler.startDocument()
-
endDocument
public void endDocument()
Description copied from interface:SimpleXMLDocHandler
Called after the document is parsed.- Specified by:
endDocument
in interfaceSimpleXMLDocHandler
- See Also:
SimpleXMLDocHandler.endDocument()
-
text
public void text(java.lang.String str)
Description copied from interface:SimpleXMLDocHandler
Called when a text element is found.- Specified by:
text
in interfaceSimpleXMLDocHandler
- Parameters:
str
- the text element, probably a fragment.- See Also:
SimpleXMLDocHandler.text(java.lang.String)
-
-