以文本方式查看主题

-  计算机科学论坛  (http://bbs.xml.org.cn/index.asp)
--  『 DOM/SAX/XPath 』  (http://bbs.xml.org.cn/list.asp?boardid=11)
----  求助各位高手  (http://bbs.xml.org.cn/dispbbs.asp?boardid=11&rootid=&id=16162)


--  作者:pepsicola
--  发布时间:3/28/2005 6:10:00 PM

--  求助各位高手
我用的dom4j,解析xml时再我的机器上一切正常,可是到了别的机器上,就有错误:
Warning: Caught exception attempting to use SAX to load a SAX XMLReader

Warning: Exception was:org.xml.sax.SAXException:Can't create default XMLReader; is system property org.xml.sax.driver set?
...
...
   at org.xml.sax.helpers.XMLHelper.createXMLReader<SAXHelper.java:67>
...
...

这是我的代码:请高手帮忙看看啊  谢拉

    try {
      SAXReader saxReader = new SAXReader();
      XMLDoc = saxReader.read(new File("config"));

      Collection collection = new ArrayList();
      java.util.List paraslist = XMLDoc.selectNodes("configure");

      for (Iterator parasitor = paraslist.iterator(); parasitor.hasNext(); ) {
        Element element = (Element) parasitor.next();
        sapHost = element.attribute("sapHost").getData().toString();
        sapClient = element.attribute("sapClient").getData().toString();
        sapSystem = element.attribute("sapSystem").getData().toString();
        sapLanguage = element.attribute("sapLanguage").getData().toString();
        sapUser = element.attribute("sapUser").getData().toString();
        sapPassword = element.attribute("sapPassword").getData().toString();
        oraHost = element.attribute("oraHost").getData().toString();
        oraPort = element.attribute("oraPort").getData().toString();
        oraSID = element.attribute("oraSID").getData().toString();
        oraUser = element.attribute("oraUser").getData().toString();
        oraPassword = element.attribute("oraPassword").getData().toString();
        hour = element.attribute("hour").getData().toString();
        minute = element.attribute("minute").getData().toString();
        second = element.attribute("second").getData().toString();
      }
    }
    catch (DocumentException e) {
      e.printStackTrace();
    }


。。。。
XMLDoc = saxReader.read(new File("config")); 这句出错。
会不会是因为文件叫 config 而不是 config.xml 的原因,但试我机器上一切正常啊。



--  作者:pepsicola
--  发布时间:3/28/2005 6:11:00 PM

--  
我的xml文件是

<?xml version="1.0" encoding="UTF-8"?>
<configure sapHost="10.1.11.2" sapClient="400" sapSystem="00" sapLanguage="EN" sapUser="fms" sapPassword="fms" oraHost="10.238.1.180" oraPort="1521" oraSID="pcitc" oraUser="pm" oraPassword="pm" hour="3" minute="0" second="0"/>


--  作者:pepsicola
--  发布时间:3/29/2005 2:42:00 PM

--  
没人帮忙啊?自己顶
W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
60.547ms