473,395 Members | 1,823 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

getElementsByTagName + documentElement

Max
Hello everyone!

i would want to know if the getElementsByTagName() function starts to find
the elements from documentElement comprising the same documentElement.

XML example:
<?xml version="1.0"?>
<exslt:module xmlns:exslt="http://exslt.org/documentation"
xmlns="http://default-ns-outter" version="1" prefix="str" exslt:foo="bah" >
....
</exslt:module>

Javascript code:
var dom = new DOMImplementation();
....
var doc = dom.doc.getDocumentElement();
var nodeList = doc.getElementsByTagName("exslt:module");

Does getElementsByTagName() function returns the first element
"exslt:module"?

Has getElementsByTagNameNS('http://exslt.org/documentation', 'module')
function the same behavior?

And getElementById(): same or different?

Best regards,

Max
Aug 9 '06 #1
1 2580


Max wrote:

Javascript code:
var dom = new DOMImplementation();
...
var doc = dom.doc.getDocumentElement();
var nodeList = doc.getElementsByTagName("exslt:module");

Does getElementsByTagName() function returns the first element
"exslt:module"?
I have no idea why you call a variable doc (like document?) if you then
assign an element to it. But your code calls getElementsByTagName on the
document element and that call will return all descendant elements of
the element it is called on but not the element itself.
You could simply do
var doc = dom.doc;
var nodeList = doc.getElementsByTagName("exslt:module");
that is call the getElementsByTagName method on the document node itself
and not on the document element.

If you have XML with namespaces then it is usually better to use
namespace aware methods like getElementsByTagNameNS. Of course that
method too when applied to the document node returns all matching
descendant elements in the document while applied to the document
element will return all matching descendant elements of the document
element.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Aug 9 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: 2obvious | last post by:
This is a pipe dream, I realize, but I'm trying to emulate the functionality of the W3C DOM-supported document.getElementsByTagName method under the very nightmarish Netscape 4. Through some...
8
by: Kyle | last post by:
I am presently making use of documentElement.innerHTML to retrieve page contents for manipulation, but I've noticed that the sting value returned is not identical to the actual page source....
23
by: Michel Bany | last post by:
I am trying to parse responseXML from an HTTP request. var doc = request.responseXML; var elements = doc.getElementsByTagName("*"); the last statement returns an empty collection when running from...
7
by: Dima | last post by:
Call to XmlNode.GetElementsByTagName returns XmlNodeList that stays in sync with XmlDocument thanks to events fired by XmlDocument. Once this list is created there is no way to remove its event...
2
by: JJA | last post by:
Here is my entire XML file - simplified to one node for testing: <root> <FlasConustbl> <ID>42101</ID> <AWARD>P015B030001</AWARD> <INSTITUTION_KEY>300</INSTITUTION_KEY> <INSTITUTION>Boston...
2
by: petermichaux | last post by:
Hi, I just tested all the browsers I have for support of document.documentElement.scrollLeft to determine how many pixels the window has been scrolled to the right. I'm trying to determine if I...
1
by: Ben | last post by:
I have a web service that returns the following xml: <?xml version="1.0" encoding="utf-8" ?> <NewDataSet> <Addresses> <XML_F52E2B61-18A1-11d1-B105-00805F49916B> <CustomerAddressBase...
21
by: Aaron Gray | last post by:
(Please tell me if this is silly or I am barking up the wrong tree) Can someone check this please on pre W3C DOM browsers :- function getDocumentRoot() { for ( e in document.childNodes) if (...
1
by: vunet | last post by:
The code below returns the viewport of the browser window but it does not work in IE7 because of the document.documentElement.clientHeight: function pageHeight(){ return window.innerHeight !=...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.