Package org.w3c.dom

Examples of org.w3c.dom.NodeList


   * @param e the element which is direct parent of all to be extracted textnodes.
   * @return the extracted String
   */
  public static String getText(final Element e)
  {
    final NodeList nl = e.getChildNodes();
    final StringBuffer result = new StringBuffer(100);

    for (int i = 0; i < nl.getLength(); i++)
    {
      final Node n = nl.item(i);
      if (n.getNodeType() == Node.TEXT_NODE)
      {
        final Text text = (Text) n;

        result.append(text.getData());
View Full Code Here


        }
    }
   
    public static String getString(Element element, String tag) {
        String s = null;
        NodeList nodes = element.getElementsByTagName(tag);
        if (nodes != null && nodes.getLength() > 0) {
            Element el = (Element) nodes.item(0);
            s = el != null && el.getFirstChild() != null ? el.getFirstChild().getNodeValue() : null;
        }
        return s;
    }
View Full Code Here

      .newInstance();
      DocumentBuilder ibatisConfigBuilder = factory.newDocumentBuilder();
      InputStream inputStream = Resources.getResourceAsStream("SqlMapConfig.xml");
      Document doc = ibatisConfigBuilder.parse(inputStream);
     
      NodeList sqlMapElem = doc.getElementsByTagName("sqlMapConfig");
     
      Element elem = doc.createElement("sqlMap");
      elem.setAttribute("resource", "sqlMap.xml");
      sqlMapElem.item(0).appendChild(elem);
     
      Transformer trans = TransformerFactory.newInstance().newTransformer();
      File tempFile = File.createTempFile("sqlMapConfig", ".xml");
      tempFile.deleteOnExit();
      trans.transform(new DOMSource(doc),new StreamResult(tempFile));
View Full Code Here

    * @return List of node returned by evaluation
    * @throws XPathExpressionException If XPath expression is invalid
    */
   protected List<Node> evaluateXPath(Node root, String xpath) throws XPathExpressionException
   {
      NodeList nl = (NodeList) xp.compile(xpath).evaluate(root, XPathConstants.NODESET);
      List<Node> list = new ArrayList<Node>(nl.getLength());
      for (int i = 0, max = nl.getLength(); i < max; i++)
      {
         list.add(nl.item(i));
      }
      return list;
   }
View Full Code Here

  }


  public int sizeOf()
  {
    NodeList nodeList = _node.getChildNodes();
    if (nodeList != null) {
      return nodeList.getLength();
    } else {
      return 0;
    }
  }
View Full Code Here

  }


  public Any getAttribute(Context context, String attribute)
  {
    NodeList nodeList = _node.getChildNodes();
    if (nodeList != null) {
      int length = nodeList.getLength();
      ArrayList vector = null;
      for(int i=0; i<length; i++) {
        Node child = nodeList.item(i);
        if (child.getNodeType() == Node.ELEMENT_NODE) {
          if (((Element)child).getTagName().equalsIgnoreCase(attribute)) {
            if (vector == null) {
              vector = new ArrayList();
            }
View Full Code Here

 
  public Any getReference(Context context, Any index)
  {
    if (index.isInt()) {
      NodeList nodeList = _node.getChildNodes();
      if (nodeList != null) {
        Node child = nodeList.item(index.toInt());
        if (child != null) {
          return new AnyNode(child);
        }
      }
    } else {
View Full Code Here

  /// @return array of children for this node. Returns empty list if
  ///    node does not have any children.
  public Any m_getChildNodes()
  {
    if (_node.hasChildNodes()) {
      NodeList nodelist = _node.getChildNodes();
      int length = nodelist.getLength();
      Any[] list = new Any[length];
      for(int i=0; i<length; i++) {
        list[i] = new AnyNode(nodelist.item(i));
      }
      return new AnyList(list);
    } else {
      return EMPTY_TUPLE;
    }
View Full Code Here

    throw new GUIException("Unknown property type [" + type + "]");
  }

  private Dimension constructDimension(Element dataNode)
    throws GUIException {
    NodeList widthNodes = dataNode.getElementsByTagName("width");
    NodeList heightNodes = dataNode.getElementsByTagName("height");

    if (widthNodes.getLength() == 1 && heightNodes.getLength() == 1) {
      try {
        int width =
          Integer.parseInt(
            XMLUtils.getStringFromChild(dataNode, "width"));
        int height =
View Full Code Here

      throw new GUIException("Invalid dimension data");
    }
  }

  private Point constructPoint(Element dataNode) throws GUIException {
    NodeList xNodes = dataNode.getElementsByTagName("x");
    NodeList yNodes = dataNode.getElementsByTagName("y");

    if (xNodes.getLength() == 1 && yNodes.getLength() == 1) {
      try {
        int x =
          Integer.parseInt(
            XMLUtils.getStringFromChild(dataNode, "x"));
        int y =
View Full Code Here

TOP

Related Classes of org.w3c.dom.NodeList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.