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 StringBufferBuffer that stores all content that is encountered. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidCalled after the document is parsed.voidendElement(String tag) Called when an end tag is found.static Stringparse(InputStream is) Static method that parses an XML InputStream.voidCalled when the document starts to be parsed.voidstartElement(String tag, Map<String, String> h) Called when a start tag is found.voidCalled 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:SimpleXMLDocHandlerCalled when a start tag is found.- Specified by:
startElementin interfaceSimpleXMLDocHandler- Parameters:
tag- the tag nameh- the tag's attributes- See Also:
-
endElement
Description copied from interface:SimpleXMLDocHandlerCalled when an end tag is found.- Specified by:
endElementin interfaceSimpleXMLDocHandler- Parameters:
tag- the tag name- See Also:
-
startDocument
public void startDocument()Description copied from interface:SimpleXMLDocHandlerCalled when the document starts to be parsed.- Specified by:
startDocumentin interfaceSimpleXMLDocHandler- See Also:
-
endDocument
public void endDocument()Description copied from interface:SimpleXMLDocHandlerCalled after the document is parsed.- Specified by:
endDocumentin interfaceSimpleXMLDocHandler- See Also:
-
text
Description copied from interface:SimpleXMLDocHandlerCalled when a text element is found.- Specified by:
textin interfaceSimpleXMLDocHandler- Parameters:
str- the text element, probably a fragment.- See Also:
-