MCPcopy Create free account
hub / github.com/HtmlUnit/htmlunit / getNamespaces

Method getNamespaces

src/main/java/org/htmlunit/html/HtmlPage.java:2334–2350  ·  view source on GitHub ↗

Returns all namespaces defined in the root element of this page. The default namespace has a key of an empty string. @return all namespaces defined in the root element of this page

()

Source from the content-addressed store, hash-verified

2332 * @return all namespaces defined in the root element of this page
2333 */
2334 public Map<String, String> getNamespaces() {
2335 final org.w3c.dom.NamedNodeMap attributes = getDocumentElement().getAttributes();
2336 final Map<String, String> namespaces = new HashMap<>();
2337 for (int i = 0; i < attributes.getLength(); i++) {
2338 final Attr attr = (Attr) attributes.item(i);
2339 String name = attr.getName();
2340 if (name.startsWith("xmlns")) {
2341 int startPos = 5;
2342 if (name.length() > 5 && name.charAt(5) == ':') {
2343 startPos = 6;
2344 }
2345 name = name.substring(startPos);
2346 namespaces.put(name, attr.getValue());
2347 }
2348 }
2349 return namespaces;
2350 }
2351
2352 /**
2353 * {@inheritDoc}

Callers 1

createElementMethod · 0.95

Calls 10

getDocumentElementMethod · 0.95
getNameMethod · 0.95
getValueMethod · 0.95
substringMethod · 0.80
lengthMethod · 0.65
getAttributesMethod · 0.45
getLengthMethod · 0.45
itemMethod · 0.45
startsWithMethod · 0.45
putMethod · 0.45

Tested by

no test coverage detected