XML和ID节点(dtd) [英] XML and ID node (dtd)

查看:69
本文介绍了XML和ID节点(dtd)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我解析XML文件以获取DOM文档。


但是当我使用方法Document.getElementsByID时(String Id)每次我
收到null。


我的XML遵循DTD。但我不知道在哪里告诉我的解析器使用这个

DTD。


我怎么能告诉它?它是否会改变上述

方法的结果?


提前,Jean-Philippe

Hi all,

I parse a XML file to get a DOM Document.

But when I use the method Document.getElementsByID(String Id) each time I
receive null.

My XML follow a DTD. But I don''t know where to tell to my parser to use this
DTD.

How can I tell it ? and does it change anything to the result of the above
method ?

thx in advance, Jean-Philippe

推荐答案




Jean-Philippe Martin写道:


Jean-Philippe Martin wrote:
我解析XML文件获取DOM文档。

但是当我每次收到null时使用方法Document.getElementsByID(String Id)。


W3C DOM中没有方法getElementsByID。有方法

document.getElementById

我的XML遵循DTD。但我不知道在哪里告诉我的解析器使用这个
DTD。

我怎么能告诉它?它是否会改变上述
方法的结果?
I parse a XML file to get a DOM Document.

But when I use the method Document.getElementsByID(String Id) each time I
receive null.
There is no method getElementsByID in the W3C DOM. There is method
document.getElementById
My XML follow a DTD. But I don''t know where to tell to my parser to use this
DTD.

How can I tell it ? and does it change anything to the result of the above
method ?




您使用的解析器是什么?你如何使用

编程语言来解析器,例如Java?


-


Martin Honnen
http://JavaScript.FAQTs.com/



Which parser are you using? How do you use the parser, with a
programming language, for instance Java?

--

Martin Honnen
http://JavaScript.FAQTs.com/



Jean-Philippe Martin写道:
Jean-Philippe Martin wrote:
我解析XML文件以获取DOM文档。

但是当我使用方法>> Document.getElementsByID(String Id)时,每个
时间我收到null。
I parse a XML file to get a DOM Document.

But when I use the method >>Document.getElementsByID(String Id) each time I receive null.


W3C DOM中没有方法getElementsByID。有>>是方法
document.getElementById


你是对的。 :o)


There is no method getElementsByID in the W3C DOM. There >>is method
document.getElementById
you''re right. :o)


我的XML遵循DTD。但是我不知道在哪里告诉>>我的解析器
来使用这个DTD。

我怎么能告诉它?并且它改变了以上方法的>>
的结果吗?

My XML follow a DTD. But I don''t know where to tell to >>my parser to use this DTD.

How can I tell it ? and does it change anything to the >>result of the above method ?



您使用的是哪个解析器?你如何使用解析器>>和编程语言,例如Java?



Which parser are you using? How do you use the parser, >>with a
programming language, for instance Java?




我已经使用了java.sun.com上提供的教程示例


这里是源代码的开头,用

Java打开并解析文件。


**************************************** />
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();


尝试{

DocumentBuilder builder = factory.newDocumentBuilder();

Document doc = builder.parse(new File(FileName));

} catch(....)


**** ****************************************


之后我能够使用doc变量。


提前致谢。

***通过Developersdex发送 http://www.developersdex.com ***

不要只是参加USENET ......获得奖励!



I''ve use the tutorial example available on java.sun.com

Here a the begining of the source code to open and parse the file with
Java.

****************************************
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();

try{
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse(new File(FileName));
} catch(....)

****************************************

After that point I''m able to use the "doc" variable.

Thanks in advance.
*** Sent via Developersdex http://www.developersdex.com ***
Don''t just participate in USENET...get rewarded for it!


Jean-Philippe Martin写道:


[Document.getElementsByID(String Id)]
Jean-Philippe Martin wrote:

[Document.getElementsByID(String Id)]
****************************************
DocumentBuilderFactory factory = DocumentBuilderFactory .newInstance();

尝试{
DocumentBuilder builder = factory.newDocumentBuilder();
文档doc = builder.parse(new File(FileName));
} catch(....)

********************************** ******

在那之后,我可以使用doc。变量。
****************************************
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();

try{
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse(new File(FileName));
} catch(....)

****************************************

After that point I''m able to use the "doc" variable.




我想,你必须启用验证才能成功使用getElementByID()。

-

Johannes Koch

in te domine speravi;非永久性的东西。

(Te Deum,4美分。)



I think, you have to enable validation to successfully use getElementByID().
--
Johannes Koch
In te domine speravi; non confundar in aeternum.
(Te Deum, 4th cent.)


这篇关于XML和ID节点(dtd)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆