haha 我没有,
不过,大过年的,帮你顶一下!

解决方案 »

  1.   

    jdk的源码?哪有jdk的源码呀?这位仁兄指点明路.
      

  2.   

    你的jdk中的 .java文件用记事本(推荐用editplus)打开就是啊
    如果是.class文件可以反编译打开
      

  3.   

    用过NanoXML吗?life版才6k(两个文件),它完成了XML的基本读写操作,很不错的;
      

  4.   

    随便找一个开源的xml解析器来改改不就行了
      

  5.   

    没用过NanoXML, 有源码嘛, 给发个怎样?
      

  6.   

    xerces
    http://xml.apache.org/xerces2-j/index.html
      

  7.   

    是啊。你看看其他XML解析器实现的方法
      

  8.   

    package myxml;
    import javax.xml.parsers.*;
    import org.w3c.dom.*;
    import org.apache.crimson.tree.*;
    import org.xml.sax.SAXException;
    import java.io.*;public class DomParserDemo{
       private  Document doc;   public DomParserDemo() throws Exception{
             DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
             DocumentBuilder builder=factory.newDocumentBuilder();
             String  source="e:/jhb1117/classes/xmldoc/candidate.xml";
             doc=builder.parse(source);
       }   public void showDocument() {
             //get all <person>
             NodeList personList=doc.getElementsByTagName(XMLTagDir.NODE_PERSON);   //"PERSON" 也可 ,本文中为数据词典
             for(int i=0;i<personList.getLength();i++)    //节点从0开始
             {
                Element person=(Element)personList.item(i);            System.out.print(XMLTagDir.NODE_NAME+":   ");
                System.out.println(getNodeValue(person,XMLTagDir.NODE_NAME));            System.out.print(XMLTagDir.NODE_ADDRESS+":   ");
                System.out.println(getNodeValue(person,XMLTagDir.NODE_ADDRESS));  System.out.print(XMLTagDir.NODE_TEL+":   ");
                System.out.println(getNodeValue(person,XMLTagDir.NODE_TEL));            System.out.print(XMLTagDir.NODE_FAX+":   ");
                System.out.println(getNodeValue(person,XMLTagDir.NODE_FAX));  System.out.print(XMLTagDir.NODE_EMAIL+":   ");
                System.out.println(getNodeValue(person,XMLTagDir.NODE_EMAIL));            System.out.println();
             }
       }   public String getNodeValue(Element person,String nodeName){
          NodeList nameList=person.getElementsByTagName(nodeName);
          Element name=(Element)nameList.item(0);
          Text text=(Text)name.getFirstChild();
          String value=text.getNodeValue();
          return value;
       }    public void saveDocument(String path) throws IOException
        {
    FileWriter fw=new FileWriter(path);
    XmlDocument xmldoc=(XmlDocument)doc;
    xmldoc.write(fw);
    fw.close();
    }
       public static void main(String args[]){
          try{
              DomParserDemo doc=new DomParserDemo();
              doc.showDocument();
    //          String path="e:/houjie/JavaAdvance/dist/xmldoc/parseOut.xml";
              String path="e:/jhb1117/classes/xmldoc/jhbparseOut.xml";
              doc.saveDocument(path);
              System.out.print("file saved");
          }catch(Exception e){
             e.printStackTrace();
          }
       }
    }
      

  9.   


    package myxml;
    import javax.xml.parsers.*;
    import org.w3c.dom.*;
    import org.apache.crimson.tree.*;
    import java.io.*;/**
     * <p>Title: </p>
     * <p>Description: </p>
     * <p>Copyright: Copyright (c) 2002</p>
     * <p>Company: </p>
     * @author xxy
     * @version 1.0
     */public class DomCreateDemo {
       private Document doc;   public DomCreateDemo() throws Exception{
          DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
          DocumentBuilder builder=factory.newDocumentBuilder();
          doc=builder.newDocument();
       }   public void createDocument(){
             if(doc==null) return;
             Element peopleElement=doc.createElement(XMLTagDir.NODE_PEOPLE);
             for(int i=1;i<=3;i++){
                Element personElement=doc.createElement(XMLTagDir.NODE_PERSON);
                personElement.setAttribute("PERSONID","E"+i);            //one person include several tags
                Text text=null;
                Element nameElement=doc.createElement(XMLTagDir.NODE_NAME);
                text=doc.createTextNode("myName"+i);
                nameElement.appendChild(text);
                personElement.appendChild(nameElement);            Element addressElement=doc.createElement(XMLTagDir.NODE_ADDRESS);
                text=doc.createTextNode("myAddress"+i);
                addressElement.appendChild(text);
                personElement.appendChild(addressElement);            Element telElement=doc.createElement(XMLTagDir.NODE_TEL);
                text=doc.createTextNode("myTel"+i);
                telElement.appendChild(text);
                personElement.appendChild(telElement);            Element faxElement=doc.createElement(XMLTagDir.NODE_FAX);
                text=doc.createTextNode("myFax"+i);
                faxElement.appendChild(text);
                personElement.appendChild(faxElement);            Element emailElement=doc.createElement(XMLTagDir.NODE_EMAIL);
                text=doc.createTextNode("myEmail"+i);
                emailElement.appendChild(text);
                personElement.appendChild(emailElement);            peopleElement.appendChild(personElement);
             }
             doc.appendChild(peopleElement);
       }   public void saveDocument(String path) throws IOException {
          FileWriter fout=new FileWriter(path);
          XmlDocument xmldoc=(XmlDocument)doc;
          xmldoc.write(fout);
          fout.close();
       }   public static void main(String[] args) {
          try{
             DomCreateDemo doc = new DomCreateDemo();
             doc.createDocument();
             System.out.print("doc created");
             String path="e:/jhb1117/classes/xmldoc/jhbcreateOut.xml";
       //      String path="e:/houjie/JavaAdvance/dist/xmldoc/createOut.xml";
             doc.saveDocument(path);
             System.out.print("file saved");
          }catch(Exception e){
             e.printStackTrace();
          }
       }
    }
      

  10.   

    package myxml;
    import javax.xml.parsers.*;
    import org.w3c.dom.*;
    import org.apache.crimson.tree.*;
    import java.io.*;/**
     * <p>Title: </p>
     * <p>Description: </p>
     * <p>Copyright: Copyright (c) 2002</p>
     * <p>Company: </p>
     * @author xxy
     * @version 1.0
     */public class DomCreateDemo {
       private Document doc;   public DomCreateDemo() throws Exception{
          DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
          DocumentBuilder builder=factory.newDocumentBuilder();
          doc=builder.newDocument();
       }   public void createDocument(){
             if(doc==null) return;
             Element peopleElement=doc.createElement(XMLTagDir.NODE_PEOPLE);
             for(int i=1;i<=3;i++){
                Element personElement=doc.createElement(XMLTagDir.NODE_PERSON);
                personElement.setAttribute("PERSONID","E"+i);            peopleElement.appendChild(personElement);
             }
             doc.appendChild(peopleElement);
       }   public void saveDocument(String path) throws IOException {
          FileWriter fout=new FileWriter(path);
          XmlDocument xmldoc=(XmlDocument)doc;
          xmldoc.write(fout);
          fout.close();
       }   public static void main(String[] args) {
          try{
             DomCreateDemo doc = new DomCreateDemo();
             doc.createDocument();
             System.out.print("doc created");
    //         String path="e:/houjie/JavaAdvance/dist/xmldoc/createOut.xml";
             String path="e:/jhb1117/classes/xmldoc/jhbcreateOut.xml";
             doc.saveDocument(path);
             System.out.print("file saved");
          }catch(Exception e){
             e.printStackTrace();
          }
       }
    }