java.lang.Object
org.htmlunit.util.XmlUtils
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Provides utility methods for working with XML responses.
Provides utility methods for working with XML responses.
- Author:
- Marc Guillemot, Ahmed Ashour, Sudhan Moghe, Ronald Brill, Chuck Dumont, Frank Danek
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidappendChild(SgmlPage page, DomNode parent, Node child, boolean handleXHTMLAsHTML) static DocumentbuildDocument(WebResponse webResponse) Builds a document from the content of the web response.static StringlookupNamespaceURI(DomElement element, String prefix) Searches for the namespace URI bound to the given prefix, starting from the specified element.static StringlookupPrefix(DomElement element, String namespace) Searches for the prefix associated with the specified namespace URI, starting from the given element.
-
Method Details
-
buildDocument
public static Document buildDocument(WebResponse webResponse) throws IOException, SAXException, ParserConfigurationException Builds a document from the content of the web response. A warning is logged if an exception is thrown while parsing the XML content (for instance when the content is not valid XML and cannot be parsed).- Parameters:
webResponse- the response from the server- Returns:
- the parse result
- Throws:
IOException- if the page could not be createdSAXException- if parsing failsParserConfigurationException- if aDocumentBuildercannot be created
-
appendChild
public static void appendChild(SgmlPage page, DomNode parent, Node child, boolean handleXHTMLAsHTML) - Parameters:
page- the owner page ofDomElements to be createdparent- the parentDomNodechild- the childNodeto appendhandleXHTMLAsHTML- iftrue, elements from the XHTML namespace are handled as HTML elements instead of DOM elements
-
lookupNamespaceURI
Searches for the namespace URI bound to the given prefix, starting from the specified element. The default namespace can be searched for by passing an empty string as the prefix.- Parameters:
element- the element to start searching fromprefix- the namespace prefix to look up; use""for the default namespace- Returns:
- the namespace URI bound to the prefix, or
nullif none is found
-
lookupPrefix
Searches for the prefix associated with the specified namespace URI, starting from the given element.- Parameters:
element- the element to start searching fromnamespace- the namespace URI to look up- Returns:
- the prefix bound to the namespace URI, or
nullif none is found
-