?? xmlparsertestutil.java
字號:
package com.yahoo;import com.yahoo.java.ExtendedError;import com.yahoo.search.SearchException;import com.yahoo.xml.XmlParser;import org.xml.sax.SAXException;import javax.xml.parsers.ParserConfigurationException;import javax.xml.parsers.SAXParser;import javax.xml.parsers.SAXParserFactory;import java.util.Map;public class XmlParserTestUtil { public static Map parseTest(String xmlPath) throws Exception { XmlParser xmlParser = null; if(xmlPath == null) { throw new Exception("xmlPath hasn't been specified, unable to parse"); } try { SAXParser parser = SAXParserFactory.newInstance().newSAXParser(); xmlParser = new XmlParser(); parser.parse(XmlParserTestUtil.class.getResourceAsStream(xmlPath), xmlParser); } catch (ParserConfigurationException e) { throw new ExtendedError("XML parser not properly configured", e); } catch (SAXException e) { throw new SearchException("Error parsing XML response", e); } return xmlParser.getRoot(); }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -