Ejemplo n.º 1
0
 /**
  * 指定项目元素的叶子节点
  *
  * @param xmlPath XML层次DOM树的路径
  * @param loc loc 层次路径中所处的位置
  */
 public Map getXmlLevelItemMap(String xmlLevelItemXPath, int loc) {
   Map leafNodeData = new HashMap();
   Iterator iter = super.xmlDomElementLeafIterator(xmlLevelItemXPath, loc);
   if (null != iter) {
     while (iter.hasNext()) {
       Entry entry = (Entry) iter.next();
       XMLNode xn = entry.xmlNode;
       leafNodeData.put(xn.getName(), xn.getValue());
     }
     return leafNodeData;
   } else {
     return null;
   }
 }
Ejemplo n.º 2
0
 /**
  * 指定项目元素的定位数据loc
  *
  * @return 指定项目下叶子节点元素集合 如:<CustOrder><EventType>3 </EventType> </CustOrder> xmlNode.nodeName
  *     元素名称(EventType);xmlNode.nodeValue 值(3);
  */
 public Map getXmlLevelItemAttrMap(String xmlLevelItemXPath) {
   Map leafNodeData = new HashMap();
   Iterator iter = super.xmlDomElementIterator(xmlLevelItemXPath);
   if (null == iter) {
     // 错误处理
     // return
   } else {
     // 遍历叶子节点
     for (; iter.hasNext(); ) {
       XMLElement xmlElement = (XMLElement) iter.next();
       XMLNodeCollection nodeCollection = xmlElement.getElementLeafNodeColl();
       for (int i = 0; i < nodeCollection.getNodesSize(); i++) {
         XMLNode node = nodeCollection.getNodesAttributeMap(i);
         leafNodeData.put(node.getName(), node.getValue());
       }
     }
   }
   return leafNodeData;
 }