Пример #1
0
 public void loadFromRootElement(Element root) {
   NodeList nodes = root.getChildNodes();
   for (int i = 0; i < nodes.getLength(); i++) {
     Node node = nodes.item(i);
     if (node.getNodeType() != Node.ELEMENT_NODE) continue;
     String key = node.getNodeName();
     LoadElement(this, (Element) node, key);
   }
 }
Пример #2
0
  private void LoadElement(WikiPageProperty context, Element element, String key) {
    WikiPageProperty newProperty = new WikiPageProperty();
    context.set(key, newProperty);

    NodeList nodes = element.getChildNodes();
    if (element.hasAttribute("value")) newProperty.setValue(element.getAttribute("value"));
    else if (nodes.getLength() == 1) newProperty.setValue(nodes.item(0).getNodeValue());

    for (int i = 0; i < nodes.getLength(); i++) {
      Node childNode = nodes.item(i);
      if (childNode instanceof Element)
        LoadElement(newProperty, (Element) childNode, childNode.getNodeName());
    }
  }