• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to substitue a DOM L2 method for getElementsByTagNameNS

 
Tom John
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to translate a DOM level 1 special method "org.w3c.dom.Element.getElementsByTagNameNS()" in DOM level 2?

I have some code finished by j2sdk1.3.(As we known, j2sdk1.3 only support DOM level 1.) In these code, there is task finished by the method of "org.w3c.dom.Element.getElementsByTagNameNS()".

Now we have updated our applications from j2sdk1.3 to j2sdk1.4. And now my JAXP support DOM level 2. So the method of "org.w3c.dom.Element.getElementsByTagNameNS()" can not get any NodeList.

I have to post a new thread here hoping you can do me a favor. I only want to know how can I substitue a DOM level 2 special method for it?

Your reply will be highly appreciated!
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13074
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So the method of "org.w3c.dom.Element.getElementsByTagNameNS()" can not get any NodeList.


I am looking at the JavaDocs for Element in Java 1.5 - I see no reason why this would not work. What happens when you try the special value "*" to match any NS?

Bill
 
Tom John
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was not tring to use "*" to match everything.

I'm using J2sdk1.4. In its API document, it describle this method as below. So I think there should be an existed solution for this issue.

==========================================
Returns a NodeList of all the descendant Elements with a given local name and namespace URI in the order in which they are encountered in a preorder traversal of this Element tree.
Documents which do not support the "XML" feature will permit only the DOM Level 1 calls for creating/setting elements and attributes. Hence, if you specify a non-null namespace URI, these DOMs will never find a matching node.

Parameters:
namespaceURI - The namespace URI of the elements to match on. The special value "*" matches all namespaces.
localName - The local name of the elements to match on. The special value "*" matches all local names.
Returns:
A new NodeList object containing all the matched Elements.
Since:
DOM Level 2
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13074
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I must be getting dense with old age because I still cant figure out exactly what your problem is. Here are the questions which occur to me:

1. Does your XML document even use namespaces?
2. What is the code used to get a NodeList in the old (sdk 1.3) code?
3. What is the code you are trying now with sdk 1.4?
4. What did you expect to happen and what actually happened?

Bill
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The question seems to be saying that some behaviour changed between Java 1.3 and Java 1.4, and wants to know how to fix it by doing some specific thing.

I for one would like to see an example of this behaviour. Sample code, sample input, results in the two versions with differences pointed out. It's pretty hard to provide a solution to the problem until you have a description of the problem.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic