java读取xml信息
来源:互联网 发布:在交换机查ip端口号 编辑:程序博客网 时间:2024/06/05 09:47
import javax.xml.parsers.DocumentBuilder;import javax.xml.parsers.DocumentBuilderFactory;import org.w3c.dom.Document;import org.w3c.dom.Element;import org.w3c.dom.Node;import org.w3c.dom.NodeList;public class XmlUtil {static String sss;public static String readXML(String file) throws Exception {DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();DocumentBuilder builder = dbf.newDocumentBuilder();Document doc = builder.parse(file); // 获取到xml文件// 下面开始读取Element root = doc.getDocumentElement(); // 获取根元素NodeList students = root.getElementsByTagName("weibo-id");for (int i = 0; i < students.getLength(); i++) {Element ss = (Element) students.item(i);NodeList names = ss.getElementsByTagName("id");Element e = (Element) names.item(0);Node t = e.getFirstChild();sss = t.toString();}return sss;}public static void main(String[] args) throws Exception {System.out.println(readXML("src/main/resources/weibo-config.xml"));}}
0 0
- java读取xml信息
- java读取xml文件的节点信息
- java- xml 本地配置信息读取
- java代码读取xml文件信息
- 读取XML文件信息
- dom4j读取XML信息
- unity 读取xml 信息
- dom4j读取xml信息
- JAVA中读取XML文件中的配置信息
- java URL类、URLConnection类读取html或xml信息
- 用java程序读取xml文件中的配置信息
- JAVA中读取XML文件中的配置信息
- 在java项目文件读取数据库文件prodect.xml信息
- PowerShell 读取xml节点信息
- 读取xml文档中的信息
- Unity3D读取XML文档信息
- 使用JDOM读取XML信息
- Unity3D读取XML文档信息
- AWK 简明教程
- VxWorks启动流程
- (an error has occurred.See error log for more details) 解决办法
- Dijkstra算法(单源最短路径)
- [linux]linux驱动模块
- java读取xml信息
- Ubuntu安装fcitx-googlepingyin
- Windows7中的VPN设置教程
- Vxworks驱动程序的结构
- OSPF 正常启动时的DEBUG包
- 百度大数据分享
- C++中的回调函数——指向类成员的指针
- Hibernate get和load区别
- 十分钟掌握diff&patch用法(转)