473,668 Members | 2,446 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

getElementsByTa gName + documentElement

Max
Hello everyone!

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

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

Javascript code:
var dom = new DOMImplementati on();
....
var doc = dom.doc.getDocu mentElement();
var nodeList = doc.getElements ByTagName("exsl t:module");

Does getElementsByTa gName() function returns the first element
"exslt:modu le"?

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

And getElementById( ): same or different?

Best regards,

Max
Aug 9 '06 #1
1 2599


Max wrote:

Javascript code:
var dom = new DOMImplementati on();
...
var doc = dom.doc.getDocu mentElement();
var nodeList = doc.getElements ByTagName("exsl t:module");

Does getElementsByTa gName() function returns the first element
"exslt:modu le"?
I have no idea why you call a variable doc (like document?) if you then
assign an element to it. But your code calls getElementsByTa gName 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.getElements ByTagName("exsl t:module");
that is call the getElementsByTa gName 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 getElementsByTa gNameNS. 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
4500
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 sleuthing, I was able to find what serves as a document.getElementById emulator at http://www.xs4all.nl/~ppk/js/dhtmloptions.html#versionb. (Below is the code; this clever algorithm is painstakingly explained at the site above.)
8
10891
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. Specifically, attribute assignments that look like: height=100 width=100 in the real source, look like: height="100" width="100"
23
15585
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 IE6. It returns the expected collection when running under Firefox or Mozilla. Anybody can explain ? Michel.
7
7149
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 handlers from the document. Calling GetElementsByTagName second time for the same tag name will create new list and add more event handlers. As result over time these handlers accumulate and reach pretty high number (millions). Every modification...
2
8654
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 University</INSTITUTION> <WORLDAREA>Africa</WORLDAREA> <STREET>270 Bay State Road</STREET>
2
9478
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 really need to go to all the trouble of feature detection for determine page scroll amount of if the old browsers are old enough now just to ignore them. Below are the OS-browser combinations that worked in my test.
1
3572
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 CustomerAddressId="259DA89E-3B3F-DB11-90EA-0016353D15C7" AddrName="PRIMARY" /> <CustomerAddressBase
21
1908
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 ( document.childNodes.nodeName == "HTML") return document.childNodes; return document.body;
1
10251
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 != null ? window.innerHeight : document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null; }
0
8371
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8889
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8572
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8652
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7391
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5677
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4202
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2017
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1779
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.