473,803 Members | 3,518 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

xmldom getAttribute firefox problem

Hi all

I am trying to get a url attribute from an xml node:
<item>
<media url="http://blablabla.com" />
</item>

I can do this in IE with the following code:
var newDom = xmlhttp.respons eXML;
var x = newDom.getEleme ntsByTagName("i tem");
var urlNode = x[0].getElementsByT agName('media') ;
var myUrl = urlNode[0].getAttribute(' url');

If I try this code in FireFox it gives me the following error:

urlNode[0] has no properties referring to this line : myUrl =
urlNode[0].getAttribute(' url');

I've tried to fix it lots of ways with no joy.

Any help is much appreciated

Thanks in advance

John

Oct 17 '07 #1
3 5900
jp*******@googl email.com wrote:
I am trying to get a url attribute from an xml node:
<item>
<media url="http://blablabla.com" />
</item>

I can do this in IE with the following code:
var newDom = xmlhttp.respons eXML;
var x = newDom.getEleme ntsByTagName("i tem");
var urlNode = x[0].getElementsByT agName('media') ;
var myUrl = urlNode[0].getAttribute(' url');

If I try this code in FireFox it gives me the following error:

urlNode[0] has no properties referring to this line : myUrl =
urlNode[0].getAttribute(' url');

I've tried to fix it lots of ways with no joy.
Firebug (1.05) test case

var s = [
'<item>',
'<media url="http://blablabla.com" />',
'</item>'
].join("\n");

try
{
var p = new DOMParser();
var newDom = p.parseFromStri ng(s, "text/xml");
var x = newDom.getEleme ntsByTagName("i tem");
var urlNode = x[0].getElementsByT agName("media") ;
var myUrl = urlNode[0].getAttribute(" url");
myUrl
}
catch (e)
{
e
}

WFM in Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.7)
Gecko/20070914 Firefox/2.0.0.7

Either you are doing something else wrong or an extension interferes.
PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
Oct 17 '07 #2
On 18 Oct, 00:11, Thomas 'PointedEars' Lahn <PointedE...@we b.de>
wrote:
jphayc...@googl email.com wrote:
I am trying to get a url attribute from an xml node:
<item>
<media url="http://blablabla.com" />
</item>
I can do this in IE with the following code:
var newDom = xmlhttp.respons eXML;
var x = newDom.getEleme ntsByTagName("i tem");
var urlNode = x[0].getElementsByT agName('media') ;
var myUrl = urlNode[0].getAttribute(' url');
If I try this code in FireFox it gives me the following error:
urlNode[0] has no properties referring to this line : myUrl =
urlNode[0].getAttribute(' url');
I've tried to fix it lots of ways with no joy.

Firebug (1.05) test case

var s = [
'<item>',
'<media url="http://blablabla.com" />',
'</item>'
].join("\n");

try
{
var p = new DOMParser();
var newDom = p.parseFromStri ng(s, "text/xml");
var x = newDom.getEleme ntsByTagName("i tem");
var urlNode = x[0].getElementsByT agName("media") ;
var myUrl = urlNode[0].getAttribute(" url");
myUrl
}
catch (e)
{
e
}

WFM in Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.7)
Gecko/20070914 Firefox/2.0.0.7

Either you are doing something else wrong or an extension interferes.

PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann- Hide quoted text -

- Show quoted text -
Thank you Thomas. You are right

A colleague has established that it is the way the xml is delivered/
formated that is causing problems

John

Oct 19 '07 #3
jp*******@googl email.com wrote:
On 18 Oct, 00:11, Thomas 'PointedEars' Lahn <PointedE...@we b.de>
wrote:
>Firebug (1.05) test case

var s = [
'<item>',
'<media url="http://blablabla.com" />',
'</item>'
].join("\n");

try
{
var p = new DOMParser();
var newDom = p.parseFromStri ng(s, "text/xml");
var x = newDom.getEleme ntsByTagName("i tem");
var urlNode = x[0].getElementsByT agName("media") ;
var myUrl = urlNode[0].getAttribute(" url");
myUrl
}
catch (e)
{
e
}

WFM in Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.7)
Gecko/20070914 Firefox/2.0.0.7

Either you are doing something else wrong or an extension interferes.
[...]
Please trim your quotes as described and recommended in the FAQ:

http://jibbering.com/faq/
Thank you Thomas. You are right

A colleague has established that it is the way the xml is delivered/
formated that is causing problems
ACK. Probably you have not served it with an XML MIME media type.

What I found most interesting when creating the test case is that Firebug
now appears to have E4X support built-in which is why

var s =
<item>
<media url="http://blablabla.com" />
</item>;

works there, too. (For DOMParser::pars eFromString(), implicit conversion
from type `xml' to type `string' then takes place.)
PointedEars
--
"Use any version of Microsoft Frontpage to create your site. (This won't
prevent people from viewing your source, but no one will want to steal it.)"
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
Oct 22 '07 #4

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

Similar topics

3
18827
by: reclusive monkey | last post by:
I am just starting out with XML. I've been playing with XML and XSLT, very nice indeed. I particularly like the filtering/ordering functions. Anyway, I have started to have a look at scripting, and would like to use JavaScript as then I use Firefox as well as IE (tried some VBScript, fine in IE of course but no go in Firefox). I have copied an example from "XML Unleashed", but when I try it, I get the following error; A Runtime Error...
2
1991
by: jfizer | last post by:
I have a web app that uses a form with its fields populated from XML using Microsoft.XMLDOM. The problem is that Microsoft.XMLDOM functions seem to run on their own thread, so I dont know when the fields are done populating. Can anyone think of a way for me to check when the following function finishes? function importXML(xmlQuery,xmlSrc,xmlTarget) {
6
10026
by: Banski | last post by:
Hi, Im quite new to XML in .Net. Im getting values from an xml file using XPath and sorting as you see in the code below. I cant figure out how to get the value of date with GetAttribute. Hope that this short description if enough and you can help to sort out this problem. Thanks in advance banski
2
12316
by: CES | last post by:
All, I'm 2 for 2 on stupid questions this works in FireFox but not in IE it's not returning the value of the style element and I'm getting error?? document.getElementById('test').innerHTML = document.getElementById('id_CompanyName').getAttribute('style'); <div class="dR4C2"> <p id="id_CompanyName" style="font-size:<%=aspNameFontSize%>px;"> <%=aspCompanyName%>
13
3237
by: Noa | last post by:
Hi I have a page that looks like that: <form name="kuku1" action ="anotherpage.html" > <input name="name"> <input name="kuku2"> </form> As far as i know, "getAttribute" should return a string value of an
2
6528
by: emma.sax | last post by:
Hi I have the following code which is working in Firefox: function showOptions() { if(!document.getElementById) return false; if(!document.getElementsByTagName) return false; var lnks = document.getElementsByTagName("a"); for(var i=0; i<lnks.length; i++) { alert(lnks.getAttribute("class"));
6
6188
by: vivekian | last post by:
Hi , In one of the javascript functions , i need to get the ids of the elements. This function works in Internet Explorer : var TabNames = ParentTab.childNodes ; for ( i = 0 ; i < TabNames.length ; i++ ) { var TabID = TabNames.getAttribute('id') ;
4
5444
by: mynameistechno | last post by:
I need to execute code in an onload event. e.g. eval(element.getAttribute('onload')); This works in Firefox but not in IE (surprise!). IE's getAttribute for the onload event seems to return an anonymous function or something. Any ideas or hacks anyone? Thanks!
4
5057
by: ICPooreMan | last post by:
I've got some code which works in firefox that's giving me fits in IE7 (maybe other versions too I haven't tested it). What I want to do is get the oncontextmenu attribute of something, change the value then put it back as the oncontextmenu attribute. Here's an example page if you want to try it out... <html> <head> <titletesting </title> <script><!--
0
9699
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9562
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
10542
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
10289
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
10068
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...
1
7600
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6840
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
5625
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3795
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.