请教各位高手:有这样一个tpl-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<xml-body>
<!--first templete -->
<tpl index="index">
<tlpPath >templete/index.html</tlpPath>
<tlpParameter tlpParameter="tlpParameterppp">
<area>###index1###</area>
<infoId>45</infoId>
<display>6</display>
<date>0</date>
<char>0</char>
</tlpParameter>
<tlpParameter>
<area>###index2###</area>
<infoId>45</infoId>
<display>6</display>
<date>0</date>
<char>0</char>
</tlpParameter>
</tpl><!--second templete -->
<tpl zk="zk">
<tlpPath>templetezk/zk.html</tlpPath>
<tlpPatameter>
<area>###zk1###</area>
<display>10</display>
</tlpPatameter>
<tlpPatameter>
<area>###zk2###</area>
<display>8</display>
</tlpPatameter>
</tpl><!--three templete -->
<tpl ck="ck">
<tlpPath>templeteck/ck.html</tlpPath>
<tlpPatameter>
<area>###ck1###</area>
<display>10</display>
</tlpPatameter>
<tlpPatameter>
<area>###ck2###</area>
<display>8</display>
</tlpPatameter>
</tpl>
</xml-body>
怎样输出各节点的名字和值???
就像:
index== index
tlpPath==templete/index.htmlarea==###index1###
infoId==45
display==6
date==0
char==0area==###index2###
infoId==45
display==6
date==0
char==0zk===zk
tlpPath==templetezk/zk.html
...循环输出全部,解决立刻给分。
<?xml version="1.0" encoding="UTF-8"?>
<xml-body>
<!--first templete -->
<tpl index="index">
<tlpPath >templete/index.html</tlpPath>
<tlpParameter tlpParameter="tlpParameterppp">
<area>###index1###</area>
<infoId>45</infoId>
<display>6</display>
<date>0</date>
<char>0</char>
</tlpParameter>
<tlpParameter>
<area>###index2###</area>
<infoId>45</infoId>
<display>6</display>
<date>0</date>
<char>0</char>
</tlpParameter>
</tpl><!--second templete -->
<tpl zk="zk">
<tlpPath>templetezk/zk.html</tlpPath>
<tlpPatameter>
<area>###zk1###</area>
<display>10</display>
</tlpPatameter>
<tlpPatameter>
<area>###zk2###</area>
<display>8</display>
</tlpPatameter>
</tpl><!--three templete -->
<tpl ck="ck">
<tlpPath>templeteck/ck.html</tlpPath>
<tlpPatameter>
<area>###ck1###</area>
<display>10</display>
</tlpPatameter>
<tlpPatameter>
<area>###ck2###</area>
<display>8</display>
</tlpPatameter>
</tpl>
</xml-body>
怎样输出各节点的名字和值???
就像:
index== index
tlpPath==templete/index.htmlarea==###index1###
infoId==45
display==6
date==0
char==0area==###index2###
infoId==45
display==6
date==0
char==0zk===zk
tlpPath==templetezk/zk.html
...循环输出全部,解决立刻给分。
解决方案 »
- 小项目。每天同时有80多个用户同时访问
- 采用接口org.apache.ibatis.session.SqlSession的实现类org.mybatis.spring.SqlSessionTemplat
- java.sql.SQLException: 违反引用约束 是为什么
- jfreechart柱形图的间隔问题
- 字符串截取
- WEB页面显示EXCEL问题
- java memcached 监控~
- 200分求JSP+JAVABEAN分页的源程序!!!!(必须是正确的)
- 用JAVA语言求n!的阶层,分别使用while,do while,for语句编程
- jsp和sql数据库连接~~~
- Acegi缓存用户信息问题
- 我给分,你要不要?
import java.io.IOException;import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;public class SAXPrinterTest extends DefaultHandler{
public void startDocument() throws SAXException {
System.out.println("<?xml version=\"1.0\" encoding=\"gbk\"?>");
}
public void processingInstruction(String taget, String data) throws SAXException {
System.out.println("<?"+taget+" " + data+ "?>");
}
public void startElement(String uri, String localName, String qName, Attributes attr) throws SAXException {
System.out.print("<" + qName);
for(int i = 0;i<attr.getLength();i++)
{
System.out.print(" ");
System.out.print(attr.getQName(i));
System.out.print("=\"");
System.out.print(attr.getValue(i));
System.out.print("\"");
}
System.out.print(">");
}
public void characters(char[] ch, int start, int length) throws SAXException {
System.out.print(new String(ch,start,length));
}
public void endElement(String uri, String localName, String qName) throws SAXException {
System.out.print("<" + qName+"/>");
}
public static void main(String args[])
{
SAXParserFactory spf = SAXParserFactory.newInstance();
try {
SAXParser sp = spf.newSAXParser();
sp.parse(new File("c:/exp/friend.xml"),new SAXPrinterTest());
} catch (ParserConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SAXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
<tpl index="index">
<tpl zk="zk">
<tpl ck="ck">
中的属性名是要给出的
今天一直上不了网!
现在给分!