为什么不用工具呢?
用Relaxer很简单的啊。
用Relaxer很简单的啊。
解决方案 »
- tomcat iis整合的问题,帮顶给分,有好方法加分~~~~~
- 请教各位高手,如何用for循环创建i个对象
- 求android手机开发资料(最好是在java基础上的)
- 关于struts2的action标签
- 请解释一下预装form的详细原理
- 综合物流管理系统源码+开发文档(j2ee+oracle)
- j2eetutorial中文版,需要的举手:)
- 请问:目前比较不错的ejb container是什么?,最好讲一下优缺点
- 为什么我在MyEclipse的Problems里只能看到一部分的Errors和Warnings?
- Eclipse中汉字倒过来,怎么回正
- 关于脱离JBuild8环境怎样运行Application和Applet
- 初学有问:为什么javac找不到“import javax.swing.JFrame;"
郁闷中,只谈技术同美食
import org.w3c.dom.*;public class DOMTest { public static void main(String[] args) throws Exception {
DOMTest dt = new DOMTest(args[0]);
} public DOMTest(String uri) throws Exception {
DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
factory.setValidating(true);
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse(uri);
displayTree(doc.getDocumentElement());
} protected void displayTree(Node node) {
short nodeType = node.getNodeType();
switch (nodeType) {
case Node.ELEMENT_NODE:
printElement((Element)node);
break;
case Node.TEXT_NODE:
printText((Text)node);
break;
case Node.COMMENT_NODE:
printComment((Comment)node);
break;
case Node.CDATA_SECTION_NODE:
printCDATA((CDATASection)node);
break;
case Node.ENTITY_REFERENCE_NODE:
printEntityReference((EntityReference)node);
break;
case Node.PROCESSING_INSTRUCTION_NODE:
printProcessingInstruction(
(ProcessingInstruction)node);
break;
default:
}
} protected void printElement(Element node) {
Node child;
Attr attr;
System.out.print("<" + node.getNodeName());
NamedNodeMap attrs = node.getAttributes();
int count = attrs.getLength();
for (int i = 0; i < count; i++) {
attr = (Attr)(attrs.item(i));
System.out.print(" " + attr.getName() + "=\"" + attr.getValue() +
"\"");
}
System.out.print(">");
NodeList children = node.getChildNodes();
count = children.getLength();
for (int i = 0; i < count; i++) {
child = children.item(i);
displayTree(child);
}
System.out.print("</" + node.getNodeName() + ">");
}
protected void printText(CharacterData node) {
System.out.print(node.getData());
} protected void printComment(Comment node) {
System.out.print("<!--" + node.getData() + "-->");
} protected void printCDATA(CDATASection node) {
System.out.print("<![CDATA[" + node.getData() + "]]>");
} protected void printEntityReference(EntityReference node) {
System.out.print("&" + node.getNodeName() + ";");
} protected void printProcessingInstruction(ProcessingInstruction node) {
System.out.print("<?" + node.getTarget() + " " + node.getData() + "?>");
}}不管什么稳当全部搞顶哈哈哈
我有没有希望拿分???
Warning: validation was turned on but an org.xml.sax.ErrorHandler was
set, which is probably not what is desired. Parser will use a defaul
ErrorHandler to print the first 10 errors. Please call
the 'setErrorHandler' method to fix this.
Error: URI=file:/E:/java/a.xml Line=2: 组件类型“Root”未被声明。
Error: URI=file:/E:/java/a.xml Line=2: 组件类型“Head”未被声明。
Error: URI=file:/E:/java/a.xml Line=2: 组件类型“Time”未被声明。
Error: URI=file:/E:/java/a.xml Line=2: 组件类型“Response”未被声明。
Error: URI=file:/E:/java/a.xml Line=2: 组件类型“ID”未被声明。
Error: URI=file:/E:/java/a.xml Line=2: 组件类型“Action”未被声明。
Error: URI=file:/E:/java/a.xml Line=2: 属性“Type”未被声明为组件“Ac
Error: URI=file:/E:/java/a.xml Line=2: 组件类型“RetCode”未被声明。
Error: URI=file:/E:/java/a.xml Line=2: 组件类型“FlyDate”未被声明。
Error: URI=file:/E:/java/a.xml Line=2: 组件类型“FromCity”未被声明。
<Root>
<Head>
<Time>
................为什么前面输出那么一段?
xml的开头又这么一行
<!DOCTYPE LIBRARY system "library.dtd">
使用来说明xml文档中的元素、属性、内容模式以及组成xml词汇表的实体
当然dtd也并不就是只有上面的那一种方法那种叫做外部dtd子集
还有一种叫做内部dtd子集
区别就是内部dtd子集不需要独立的文件但是dtd被声明再xml文档的开头呵呵你还是找一本xml的书看看吧
我这里只能说明又这么一回事,真正要弄明白还要看书
asdmonster(努力学习VC,讨回失去的信誉分) (
兄台,非常感谢你的留言,但事实上我的给分是阴差阳错的给错了。
我那200分就算是你给我留言的分吧
你能不能开一个帖子给100分给gunnery(射手) 回答我问题的兄弟?
因为我的可用分只有500多,不算多,如果不可以,也请留言给我,那我只有自己去开贴给分了
555555555555555555aaaaaaaaa...........