コード例 #1
0
ファイル: XMLParser.java プロジェクト: Jieee/nova
  @Override
  public void startElement(String uri, String localName, String qName, Attributes attributes)
      throws SAXException {

    /* Check if the root node has been created yet */
    if (rootNode == null) {
      currentNode = rootNode = new XMLNode(qName);
    } else {

      /* Create the new node and push the current node to the stack before reassigning its value */
      XMLNode newNode = new XMLNode(qName);
      nodeStack.push(currentNode);
      currentNode = newNode;
    }

    /* Add all the attributes to the current node */
    for (int i = 0; i < attributes.getLength(); i++) {
      currentNode.addAttribute(attributes.getQName(i), attributes.getValue(i));
    }
  }