Package org.htmlunit.html
Class XmlSerializer
- java.lang.Object
-
- org.htmlunit.html.XmlSerializer
-
public class XmlSerializer extends java.lang.Object
Utility to handle conversion from HTML code to XML string.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringBuilder
builder_
private static java.util.regex.Pattern
CREATE_FILE_PATTERN
private static java.lang.String
FILE_SEPARATOR
private java.lang.StringBuilder
indent_
private static org.apache.commons.logging.Log
LOG
private java.io.File
outputDir_
-
Constructor Summary
Constructors Constructor Description XmlSerializer()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
asText(DomNode node)
java.lang.String
asXml(DomElement node)
private static java.util.Map<java.lang.String,DomAttr>
createAttributesCopyWithClonedAttribute(HtmlElement elt, java.lang.String attrName)
private java.io.File
createFile(java.lang.String url, java.lang.String extension)
Computes the best file to save the response to the given URL.private java.util.Map<java.lang.String,DomAttr>
getAttributesFor(BaseFrameElement frame)
protected java.util.Map<java.lang.String,DomAttr>
getAttributesFor(HtmlImage image)
protected java.util.Map<java.lang.String,DomAttr>
getAttributesFor(HtmlLink link)
private static java.lang.String
getFileExtension(Page enclosedPage)
private static java.lang.String
getSuffix(WebResponse response)
protected boolean
isExcluded(DomElement element)
protected void
printOpeningTag(DomElement node)
Prints the content between "<" and ">" (or "/>") in the output of the tag name and its attributes in XML format.protected void
printText(DomNode node)
protected void
printXml(DomElement node)
private java.util.Map<java.lang.String,DomAttr>
readAttributes(DomElement node)
void
save(SgmlPage page, java.io.File file)
private void
save(SgmlPage page, java.io.File file, boolean append)
-
-
-
Field Detail
-
FILE_SEPARATOR
private static final java.lang.String FILE_SEPARATOR
- See Also:
- Constant Field Values
-
CREATE_FILE_PATTERN
private static final java.util.regex.Pattern CREATE_FILE_PATTERN
-
LOG
private static final org.apache.commons.logging.Log LOG
-
builder_
private final java.lang.StringBuilder builder_
-
indent_
private final java.lang.StringBuilder indent_
-
outputDir_
private java.io.File outputDir_
-
-
Method Detail
-
save
public void save(SgmlPage page, java.io.File file) throws java.io.IOException
- Throws:
java.io.IOException
-
save
private void save(SgmlPage page, java.io.File file, boolean append) throws java.io.IOException
- Throws:
java.io.IOException
-
asXml
public java.lang.String asXml(DomElement node) throws java.io.IOException
- Parameters:
node
- a node- Returns:
- the xml representation according to the setting of this serializer
- Throws:
java.io.IOException
- in case of problem saving resources
-
printXml
protected void printXml(DomElement node) throws java.io.IOException
- Throws:
java.io.IOException
-
asText
public java.lang.String asText(DomNode node)
- Parameters:
node
- a node- Returns:
- the text representation according to the setting of this serializer
-
printText
protected void printText(DomNode node)
-
printOpeningTag
protected void printOpeningTag(DomElement node) throws java.io.IOException
Prints the content between "<" and ">" (or "/>") in the output of the tag name and its attributes in XML format.- Parameters:
node
- the node whose opening tag is to be printed- Throws:
java.io.IOException
- in case of problem saving resources
-
readAttributes
private java.util.Map<java.lang.String,DomAttr> readAttributes(DomElement node) throws java.io.IOException
- Throws:
java.io.IOException
-
getAttributesFor
private java.util.Map<java.lang.String,DomAttr> getAttributesFor(BaseFrameElement frame) throws java.io.IOException
- Throws:
java.io.IOException
-
getFileExtension
private static java.lang.String getFileExtension(Page enclosedPage)
-
getAttributesFor
protected java.util.Map<java.lang.String,DomAttr> getAttributesFor(HtmlLink link) throws java.io.IOException
- Throws:
java.io.IOException
-
getAttributesFor
protected java.util.Map<java.lang.String,DomAttr> getAttributesFor(HtmlImage image)
-
getSuffix
private static java.lang.String getSuffix(WebResponse response)
-
createAttributesCopyWithClonedAttribute
private static java.util.Map<java.lang.String,DomAttr> createAttributesCopyWithClonedAttribute(HtmlElement elt, java.lang.String attrName)
-
isExcluded
protected boolean isExcluded(DomElement element)
-
createFile
private java.io.File createFile(java.lang.String url, java.lang.String extension) throws java.io.IOException
Computes the best file to save the response to the given URL.- Parameters:
url
- the requested URLextension
- the preferred extension- Returns:
- the file to create
- Throws:
java.io.IOException
- if a problem occurs creating the file
-
-