小编Aan*_*shi的帖子

DOM XML Parser示例

我有这个XML文件.我只是解析这个XML文件.这个例子展示了如何通过"name"获取节点,并显示值.如何显示数据库中的所有记录?

<data399173_eff_sor>
<record>
    <ID>1</ID>
    <item_no>1.0</item_no>
    <description>Hack off tiles and make good walls</description>
    <price>100</price>
    <base_qty>50</base_qty>
    <var_qty>20</var_qty>
    <base_price_>5000</base_price_>   
</record>
<record>
    <ID>1</ID>
    <item_no>1.03</item_no>
    <description>Test</description>
    <price>45</price>
    <base_qty>100</base_qty>
    <var_qty>4500</var_qty>
    <base_price_>0</base_price_>
</record>
</data399173_eff_sor>
Run Code Online (Sandbox Code Playgroud)

等等

Java代码

   File fXmlFile = new File("D:/formdata.xml");
    DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
    Document doc = dBuilder.parse(fXmlFile);

    doc.getDocumentElement().normalize();

    System.out.println("Root element :" + doc.getDocumentElement().getNodeName());

    NodeList nList = doc.getElementsByTagName("record");

    System.out.println("----------------------------");

    for (int temp = 0; temp < nList.getLength(); temp++) {

        Node nNode = nList.item(temp);

        System.out.println("\nCurrent Element :" + nNode.getNodeName());

        if (nNode.getNodeType() == Node.ELEMENT_NODE) …
Run Code Online (Sandbox Code Playgroud)

java xml

6
推荐指数
2
解决办法
3万
查看次数

System类和PrintStream类之间有什么关系

我想知道 System.out.println() 到底是什么。我读了这两篇文章 What is System, out, println in System.out.println() in JavaWhat's the meaning of System.out.println in Java? 。我知道什么是 System、out 和 print,但我不知道 System 类如何连接到PrintStream class. 他们怎么样related to each other

System是一个类,java.lang package.out是System类的静态成员,那么它是如何成为一个实例的呢java.io.PrintStream?System和PrintStream是如何相互关联的?

java system.out

5
推荐指数
1
解决办法
2472
查看次数

标签 统计

java ×2

system.out ×1

xml ×1