📄 simpledigester--rosonsandy.htm
字号:
System.out.println(students.get(i));
}
System.out.println(a.getName());
//(3)
// File file=new File("academy.xml");
// InputSource input=new InputSource("file://"+file.getAbsolutePath());
// FileInputStream fis=new FileInputStream(file);
// input.setByteStream(fis);
// digester.push(this);
// digester.parse(input);
// fis.close();
}
catch(Exception e)
{
System.out.println(e);
System.exit(1);
}
}
}
</PRE></DIV>
<P><A name=#d></A></P>
<DIV
style="PADDING-RIGHT: 5px; PADDING-LEFT: 5px; PADDING-BOTTOM: 5px; MARGIN: 5px; FONT: 11px/110% Andale Mono, Courier New, Courier, monospace; OVERFLOW: visible; WIDTH: 550px; PADDING-TOP: 5px; WHITE-SPACE: pre; BACKGROUND-COLOR: #efefef"><PRE style="COLOR: #006600; FONT-FAMILY: Andale Mono, Courier New, Courier, monospace"><B>Student.java</B>
/*
* Created on 2005-11-6
* @Author roson
*/
import java.util.Vector;
public class Student {
private Vector<Course> courses;
private String name;
private String division;
public Student()
{
courses=new Vector<Course>();
}
public void addCourse(Course course)
{
courses.addElement(course);
}
public Vector getCourses()
{
return courses;
}
public void setCourses(Vector<Course> courses)
{
this.courses = courses;
}
public String getDivision()
{
return division;
}
public void setDivision(String division)
{
this.division = division;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public String toString()
{
StringBuffer buf=new StringBuffer(60);
buf.append("\nStudent Name>>"+this.getName());
Vector courses=this.getCourses();
for(int i=0;i<courses.size();i++)
{
buf.append(courses.get(i));
}
return buf.toString();
}
}
</PRE></DIV>
<P><A name=#e></A></P>
<DIV
style="PADDING-RIGHT: 5px; PADDING-LEFT: 5px; PADDING-BOTTOM: 5px; MARGIN: 5px; FONT: 11px/110% Andale Mono, Courier New, Courier, monospace; OVERFLOW: visible; WIDTH: 550px; PADDING-TOP: 5px; WHITE-SPACE: pre; BACKGROUND-COLOR: #efefef"><PRE style="COLOR: #006600; FONT-FAMILY: Andale Mono, Courier New, Courier, monospace"><B>Teacher.java</B>
/*
* Created on 2005-11-6
* @Author roson
*/
import java.util.Vector;
public class Teacher {
private String name;
private Vector<String> certifications;
public Teacher()
{
certifications=new Vector<String>();
}
public void addCertification(String certification)
{
certifications.addElement(certification);
}
public Vector getCertifications()
{
return certifications;
}
public void setCertifications(Vector<String> certifications)
{
this.certifications = certifications;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public String toString()
{
StringBuffer buf=new StringBuffer(60);
buf.append("\nTeacher name>>"+this.getName());
Vector certs=this.getCertifications();
for(int i=0;i<CERTS.SIZE();I++) buf.append(?\n\tcertification="" {="" />>"+certs.get(i));
}
return buf.toString();
}
}
</PRE></DIV>
<P><A name=#f></A></P>
<DIV
style="PADDING-RIGHT: 5px; PADDING-LEFT: 5px; PADDING-BOTTOM: 5px; MARGIN: 5px; FONT: 11px/110% Andale Mono, Courier New, Courier, monospace; OVERFLOW: visible; WIDTH: 550px; PADDING-TOP: 5px; WHITE-SPACE: pre; BACKGROUND-COLOR: #efefef"><PRE style="COLOR: #006600; FONT-FAMILY: Andale Mono, Courier New, Courier, monospace"><B>academy.xml</B>
<?xml version="1.0"?>
<academy name="JAcademy">
<student name="JavaBoy" division="A">
<course>
<id>C1</id>
<name>JSP</name>
</course>
<course>
<id>C2</id>
<name>Servlets</name>
</course>
</student>
<stduent name="JavaGirl" division="B">
<course>
<id>C3</id>
<name>EJB</name>
</course>
</stduent>
<teacher name="JavaGuru">
<certification>SCJP</certification>
<certification>SCWCD</certification>
</teacher>
<teacher name="JavaMaster">
<certification>OCP</certification>
<certification>SCJP</certification>
<certification>SCEA</certification>
</teacher>
</academy>
</PRE></DIV>
<P>参考文章: <BR><A
href="http://www.theserverside.com/articles/article.tss?l=Digester"><FONT
color=#0000ff>http://www.theserverside.com/articles/article.tss?l=Digester</FONT></A>
<BR><A
href="http://www.onjava.com/pub/a/onjava/2002/10/23/digester.html?page=1"><FONT
color=#0000ff>http://www.onjava.com/pub/a/onjava/2002/10/23/digester.html?page=1</FONT></A>
<BR></P>
<P></P>
<P class=diaryFoot>- 作者: <A
onclick="window.open('http://publishblog.blogdriver.com/blog/postMessage.b?receiver=517836','发送短消息','width=520, height=455')"
href="javascript:void(0);">rosonsandy</A> 2005年11月6日, 星期日 20:27 </P></DIV>
<DIV class=operation><A name=trackback>
<H3>Trackback</H3></A>
<P class=trackback>你可以使用这个链接引用该篇日志
http://publishblog.blogdriver.com/blog/tb.b?diaryID=1044354 </P></DIV>
<DIV class=operation><A name=relatedDiary>
<H3>博客手拉手</H3></A>
<TABLE width="90%">
<TBODY></TBODY></TABLE></DIV>
<DIV class=operation><A name=comment>
<H3>回复</H3></A><A name=comment$(remark.remarkID)>
<H4>- 评论人:niehanzi </H4></A>
<H5>Tue Jun 05 09:18:52 CST 2007 <A href="mailto:kedahanzi@163.com"><IMG
class=imgStyle height=12 alt=作者邮箱
src="simpleDigester--rosonsandy.files/letter.gif" width=16 align=absMiddle
border=0></A> <A href="http:///" target=_blank><IMG class=imgStyle height=14
alt=作者Blog src="simpleDigester--rosonsandy.files/blog_2.gif" width=16
align=textTop border=0></A> </H5><BR>
<P
class=comment>您好!用Digester解析xml文件设置的规则的时候设置的顺序从道理上讲应该是没有关系的吧,但是我调整了一下设置的规则的顺序,发现有的时候出错,有的时候没有问题,这是为什么啊?<BR><BR></P></DIV>
<DIV class=operation>
<TABLE class=comment cellSpacing=0 cellPadding=0 width=700 border=0>
<FORM id=replyForm method=post><INPUT type=hidden value=356891 name=blogID>
<INPUT type=hidden value=1044354 name=diaryID> <INPUT type=hidden
value=rosonsandy name=blogDomino>
<SCRIPT>
if(getCookie('userID') == null){
document.write('<tr><td width="70">发布人:</td>');
document.write('<td width="150"> <input name="remark.authorNameFUI" type="text" size="20" class="inputStyle" maxlength="20"></td>');
document.write('<td width="70">邮箱:</td>');
document.write('<td width="435"> <input name="remark.authorEmail" type="text" size="20" class="inputStyle" maxlength="40"></td>');
document.write('</tr><tr><td>主 页:</td>');
document.write('<td colspan="3"> <input name="remark.authorURL" type="text" class="inputStyle" value="HTTP://" size="63" maxlength="40"></td></tr>');
}else{
document.write('<input type="hidden" name="remark.authorNameFUI" value="Blogdriver">');
}
</SCRIPT>
<TBODY>
<TR align=left>
<TD colSpan=4>评论内容:<BR><TEXTAREA class=textStyle id=remark name=remark.remarkFUI rows=8 cols=60> </TEXTAREA>
</TD></TR>
<TR align=left>
<TD colSpan=4> <INPUT onclick=reply() type=button value=提交>
<INPUT type=reset value=重置> </TD></TR></FORM></TBODY></TABLE></DIV></DIV>
<SCRIPT src="" type=text/javascript></SCRIPT>
<DIV id=footer><A
href="http://statices.blogdriver.com/jsp/reg/register.jsp"><IMG class=logo
src="simpleDigester--rosonsandy.files/logo3.gif" border=0></A><A
href="http://www.blogdriver.com/">2003-2004 BLOGDRIVER.COM All rights
reserved</A></DIV></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -