Package com.itextpdf.text.xml
Class XmlToTxt
java.lang.Object
com.itextpdf.text.xml.XmlToTxt
- All Implemented Interfaces:
SimpleXMLDocHandler
This class converts XML into plain text stripping all tags.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringBuffer
Buffer that stores all content that is encountered. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Called after the document is parsed.void
endElement
(String tag) Called when an end tag is found.static String
parse
(InputStream is) Static method that parses an XML InputStream.void
Called when the document starts to be parsed.void
startElement
(String tag, Map<String, String> h) Called when a start tag is found.void
Called when a text element is found.toString()
-
Field Details
-
buf
Buffer that stores all content that is encountered.
-
-
Constructor Details
-
XmlToTxt
protected XmlToTxt()Creates an instance of XML to TXT.
-
-
Method Details
-
parse
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:
IOException
-
toString
-
startElement
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:
-
endElement
Description copied from interface:SimpleXMLDocHandler
Called when an end tag is found.- Specified by:
endElement
in interfaceSimpleXMLDocHandler
- Parameters:
tag
- the tag name- See Also:
-
startDocument
public void startDocument()Description copied from interface:SimpleXMLDocHandler
Called when the document starts to be parsed.- Specified by:
startDocument
in interfaceSimpleXMLDocHandler
- See Also:
-
endDocument
public void endDocument()Description copied from interface:SimpleXMLDocHandler
Called after the document is parsed.- Specified by:
endDocument
in interfaceSimpleXMLDocHandler
- See Also:
-
text
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:
-