📄 trimvalue.java~2~
字号:
import java.util.*;import java.io.*;import java.sql.Timestamp;import org.w3c.dom.*;import org.apache.xerces.parsers.DOMParser;public class trimvalue { private static final String xmlFile = "new-xml/2.xml"; //public trimvalue(){ public static void main(String args[]) { try { Document xml = StockHelper.parseXMLFromFile(new File(xmlFile)); Element root = xml.getDocumentElement(); //int stocklen = root.getElementsByTagName("stock").getChildNodes().getLength(); NodeList nl = root.getElementsByTagName("stock"); Element stock = (Element)nl.item(0); int rootlen = nl.getLength(); // stock 节点的个数 int stocklen = stock.getChildNodes().getLength(); // 15 //System.out.print((stock.getChildNodes().getLength()-1)/2); //for(int i=0;i<rootlen;i++){ ///for(int j=1;j<stocklen;j=j+2){ //String value=nl.item(i).getChildNodes().item(j).getChildNodes().item(0).getNodeValue(); root.removeChild(nl.item(0)); // } //} } catch (XMLHelperException xmlhe) { System.err.println( "There was an error in the extraction process:\n" + xmlhe.getMessage()); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -