more..
package hufs.File.Xml;
import java.io.*;
import javax.xml.parsers.*;
import org.w3c.dom.*;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
class XmlPaser {
private DocumentBuilderFactory factory;
private DocumentBuilder builder;
private String type = null;
private File fs;
private FileInputStream fis;
private InputSource is;
private Document doc;
private NodeList nodelist;
private int count = -1;
private DocumentBuilder builder;
private String type = null;
private File fs;
private FileInputStream fis;
private InputSource is;
private Document doc;
private NodeList nodelist;
private int count = -1;
public XmlPaser(String name) {
this.type = name;
try {
initial();
} catch (Exception e) {
e.printStackTrace();
}
try {
initial();
} catch (Exception e) {
e.printStackTrace();
}
}
public void initial() throws Exception {
try {
factory = DocumentBuilderFactory.newInstance();
factory.setValidating(false);
factory.setValidating(false);
builder = factory.newDocumentBuilder();
fs = new File("Server/xml/" + type + ".xml");
fis = new FileInputStream(fs);
is = new InputSource(fis);
doc = builder.parse(is);
fs = new File("Server/xml/" + type + ".xml");
fis = new FileInputStream(fs);
is = new InputSource(fis);
doc = builder.parse(is);
nodelist = ((org.w3c.dom.Document) doc)
.getElementsByTagName("name");
.getElementsByTagName("name");
} catch (Exception e) {
e.printStackTrace();
System.out.println(e.getMessage());
}
}
e.printStackTrace();
System.out.println(e.getMessage());
}
}
public String getname() {
Node node;
count++;
Element nod = (Element) nodelist.item(count);
node = nod.getFirstChild();
node = nod.getFirstChild();
return String.valueOf(node.getNodeValue());
}
public int getsize(){
return nodelist.getLength();
}
public boolean exist() {
return nodelist.getLength();
}
public boolean exist() {
if (nodelist.getLength() == count + 1)
return false;
else
return true;
}
return false;
else
return true;
}
public void clear() {
count = -1;
}
count = -1;
}
}
댓글 없음:
댓글 쓰기