permaculture playing cards*
The moose likes XML and Related Technologies and the fly likes How to substitue a DOM L2  method  for getElementsByTagNameNS Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "How to substitue a DOM L2  method  for getElementsByTagNameNS" Watch "How to substitue a DOM L2  method  for getElementsByTagNameNS" New topic
Author

How to substitue a DOM L2 method for getElementsByTagNameNS

Tom John
Greenhorn

Joined: Apr 15, 2002
Posts: 29
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

Joined: Mar 22, 2000
Posts: 12781
    
    5
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

Joined: Apr 15, 2002
Posts: 29
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

Joined: Mar 22, 2000
Posts: 12781
    
    5
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
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to substitue a DOM L2 method for getElementsByTagNameNS