/** * Returns attribute value. Returns <code>null</code> when * attribute doesn't exist or when attribute exist but doesn't * specify a value. */ public String getAttribute(final String name) { Attribute attribute = getAttributeInstance(name); if (attribute == null) { return null; } return attribute.getValue(); }
/** * Renders attribute. */ protected void renderAttribute(final Node node, final Attribute attribute, final Appendable appendable) throws IOException { String name = resolveAttributeName(node, attribute); String value = attribute.getValue(); appendable.append(name); if (value != null) { appendable.append('='); appendable.append('\"'); appendable.append(HtmlEncoder.attributeDoubleQuoted(value)); appendable.append('\"'); } }
@Test void testCombinators() throws IOException { NodeSelector nodeSelector = createNodeFilter(); List<Node> nodes = nodeSelector.select("p#text > span"); assertEquals(1, nodes.size()); Node spanNode = nodes.get(0); assertEquals("spanner", (spanNode.getChild(0)).getNodeValue()); nodes = nodeSelector.select("p#text > em"); assertEquals(3, nodes.size()); nodes = nodeSelector.select("p#text > em#oleg + em"); assertEquals(0, nodes.size()); nodes = nodeSelector.select("p#text > em#oleg + span"); assertEquals(1, nodes.size()); assertEquals("spanner", (nodes.get(0).getChild(0)).getNodeValue()); nodes = nodeSelector.select("p#text > em#oleg ~ em"); assertEquals(1, nodes.size()); assertEquals("lina", nodes.get(0).getAttribute(0).getValue()); }
assertEquals("ema", nodes.get(0).getAttribute(0).getValue());
assertEquals("w173", attr.getValue()); assertTrue(p.hasAttribute("id"));
/** * Returns attribute value. Returns <code>null</code> when * attribute doesn't exist or when attribute exist but doesn't * specify a value. */ public String getAttribute(final String name) { Attribute attribute = getAttributeInstance(name); if (attribute == null) { return null; } return attribute.getValue(); }
/** * Returns attribute value. Returns <code>null</code> when * attribute doesn't exist or when attribute exist but doesn't * specify a value. */ public String getAttribute(String name) { Attribute attribute = getAttributeInstance(name); if (attribute == null) { return null; } return attribute.getValue(); }
/** * Returns attribute value. Returns <code>null</code> when * attribute doesn't exist or when attribute exist but doesn't * specify a value. */ public String getAttribute(String name) { Attribute attribute = getAttributeInstance(name); if (attribute == null) { return null; } return attribute.getValue(); }
/** * Renders attribute. */ protected void renderAttribute(final Node node, final Attribute attribute, final Appendable appendable) throws IOException { String name = resolveAttributeName(node, attribute); String value = attribute.getValue(); appendable.append(name); if (value != null) { appendable.append('='); appendable.append('\"'); appendable.append(HtmlEncoder.attributeDoubleQuoted(value)); appendable.append('\"'); } }
/** * Renders attribute. */ protected void renderAttribute(Node node, Attribute attribute, Appendable appendable) throws IOException { String name = resolveAttributeName(node, attribute); String value = attribute.getValue(); appendable.append(name); if (value != null) { appendable.append('='); appendable.append('\"'); appendable.append(HtmlEncoder.attributeDoubleQuoted(value)); appendable.append('\"'); } }