Package org.jsoup.helper
Class W3CDom
- java.lang.Object
-
- org.jsoup.helper.W3CDom
-
public class W3CDom extends Object
Helper class to transform aDocument
to aorg.w3c.dom.Document
, for integration with toolsets that use the W3C DOM.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
W3CDom.W3CBuilder
Implements the conversion by walking the input.
-
Field Summary
Fields Modifier and Type Field Description protected DocumentBuilderFactory
factory
-
Constructor Summary
Constructors Constructor Description W3CDom()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description String
asString(Document doc)
Serialize a W3C document to a String.static String
asString(Document doc, Map<String,String> properties)
Serialize a W3C document to a String.static Document
convert(Document in)
Converts a jsoup DOM to a W3C DOMvoid
convert(Document in, Document out)
Converts a jsoup document into the provided W3C Document.Document
fromJsoup(Document in)
Convert a jsoup Document to a W3C Document.static HashMap<String,String>
OutputHtml()
Canned default for HTML output.static HashMap<String,String>
OutputXml()
Canned default for XML output.
-
-
-
Field Detail
-
factory
protected DocumentBuilderFactory factory
-
-
Method Detail
-
convert
public static Document convert(Document in)
Converts a jsoup DOM to a W3C DOM- Parameters:
in
- jsoup Document- Returns:
- W3C Document
-
asString
public static String asString(Document doc, Map<String,String> properties)
Serialize a W3C document to a String. Provide Properties to define output settings including if HTML or XML. If you don't provide the properties (null
), the output will be auto-detected based on the content of the document.- Parameters:
doc
- Documentproperties
- (optional/nullable) the output properties to use. SeeTransformer.setOutputProperties(Properties)
andOutputKeys
- Returns:
- Document as string
- See Also:
OutputHtml()
,OutputXml()
,OutputKeys.ENCODING
,OutputKeys.OMIT_XML_DECLARATION
,OutputKeys.STANDALONE
,OutputKeys.STANDALONE
,OutputKeys.DOCTYPE_PUBLIC
,OutputKeys.DOCTYPE_PUBLIC
,OutputKeys.CDATA_SECTION_ELEMENTS
,OutputKeys.INDENT
,OutputKeys.MEDIA_TYPE
-
fromJsoup
public Document fromJsoup(Document in)
Convert a jsoup Document to a W3C Document.- Parameters:
in
- jsoup doc- Returns:
- w3c doc
-
convert
public void convert(Document in, Document out)
Converts a jsoup document into the provided W3C Document. If required, you can set options on the output document before converting.- Parameters:
in
- jsoup docout
- w3c doc- See Also:
fromJsoup(org.jsoup.nodes.Document)
-
asString
public String asString(Document doc)
Serialize a W3C document to a String. The output format will be XML or HTML depending on the content of the doc.- Parameters:
doc
- Document- Returns:
- Document as string
- See Also:
asString(Document, Map)
-
-