/** * Removes the element, text or attribute that matches the supplied XPath expression. * * @param key an XPath expression. * @return the previous value of the matched node if any. * @throws RuntimeException if the XPath expression isn't valid. */ public String remove(String key) { if (root == null) return null; try { Node node = getXMLUtil().selectSingleNode(root, key); if (node != null) { String value = getXMLUtil().getNormalizedValue(node); if (node.getNodeType() == Node.ATTRIBUTE_NODE) ((Attr)node).getOwnerElement().removeAttribute(node.getNodeName()); else node.getParentNode().removeChild(node); return value; } } catch(Exception e) { throw new RuntimeException(e); } return null; }
/** * Removes the element, text or attribute that matches the supplied XPath expression. * * @param key an XPath expression. * @return the previous value of the matched node if any. * @throws RuntimeException if the XPath expression isn't valid. */ public String remove(String key) { if (root == null) return null; try { Node node = getXMLUtil().selectSingleNode(root, key); if (node != null) { String value = getXMLUtil().getNormalizedValue(node); if (node.getNodeType() == Node.ATTRIBUTE_NODE) ((Attr)node).getOwnerElement().removeAttribute(node.getNodeName()); else node.getParentNode().removeChild(node); return value; } } catch(Exception e) { throw new RuntimeException(e); } return null; }
/** * Removes the element, text or attribute that matches the supplied XPath expression. * * @param key an XPath expression. * @return the previous value of the matched node if any. * @throws RuntimeException if the XPath expression isn't valid. */ public String remove(String key) { if (root == null) return null; try { Node node = getXMLUtil().selectSingleNode(root, key); if (node != null) { String value = getXMLUtil().getNormalizedValue(node); if (node.getNodeType() == Node.ATTRIBUTE_NODE) ((Attr)node).getOwnerElement().removeAttribute(node.getNodeName()); else node.getParentNode().removeChild(node); return value; } } catch(Exception e) { throw new RuntimeException(e); } return null; }
/** * Removes the element, text or attribute that matches the supplied XPath expression. * * @param key an XPath expression. * @return the previous value of the matched node if any. * @throws RuntimeException if the XPath expression isn't valid. */ public String remove(String key) { if (root == null) return null; try { Node node = getXMLUtil().selectSingleNode(root, key); if (node != null) { String value = getXMLUtil().getNormalizedValue(node); if (node.getNodeType() == Node.ATTRIBUTE_NODE) ((Attr)node).getOwnerElement().removeAttribute(node.getNodeName()); else node.getParentNode().removeChild(node); return value; } } catch(Exception e) { throw new RuntimeException(e); } return null; }
/** * Returns the text value of the element (or attribute or text) that matches the supplied * XPath expression. * * @param key an XPath expression. * @return the text value of the matched element or null if the element does not exist or have * no value. * @throws RuntimeException if the XPath expression isn't correct. */ public String get(String key) { if (root == null) return null; try { return getXMLUtil().getNormalizedValue(getXMLUtil().selectSingleNode(root, key)); } catch (Exception e) { throw new RuntimeException(e); } }
/** * Returns the text value of the element (or attribute or text) that matches the supplied * XPath expression. * * @param key an XPath expression. * @return the text value of the matched element or null if the element does not exist or have * no value. * @throws RuntimeException if the XPath expression isn't correct. */ public String get(String key) { if (root == null) return null; try { return getXMLUtil().getNormalizedValue(getXMLUtil().selectSingleNode(root, key)); } catch (Exception e) { throw new RuntimeException(e); } }
/** * Returns the text value of the element (or attribute or text) that matches the supplied * XPath expression. * * @param key an XPath expression. * @return the text value of the matched element or null if the element does not exist or have * no value. * @throws RuntimeException if the XPath expression isn't correct. */ public String get(String key) { if (root == null) return null; try { return getXMLUtil().getNormalizedValue(getXMLUtil().selectSingleNode(root, key)); } catch (Exception e) { throw new RuntimeException(e); } }
/** * Returns the text value of the element (or attribute or text) that matches the supplied * XPath expression. * * @param key an XPath expression. * @return the text value of the matched element or null if the element does not exist or have * no value. * @throws RuntimeException if the XPath expression isn't correct. */ public String get(String key) { if (root == null) return null; try { return getXMLUtil().getNormalizedValue(getXMLUtil().selectSingleNode(root, key)); } catch (Exception e) { throw new RuntimeException(e); } }