473,320 Members | 1,857 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,320 software developers and data experts.

How to get elements from XML using DOM in Javascript

I am getting an error...

elem is null or not an object using the following Client side javascript.

Can someone give me some help? Thanks in advance.

<XML ID="PB">
<ProductItem>
<Product ID="Adhesive">
<ItemType>Machine</ItemType>
</Product>
</ProductItem>
</XML>

<script language=javascript>

var root = new ActiveXObject("Microsoft.XMLDOM")
var xmldoc = new ActiveXObject("Microsoft.XMLDOM")
xmldoc.async = false;
xmldoc = document.getElementById("PB")
root = xmldoc.documentElement;

elem = root.getElementsByTagName("Product").item(0).docum entElement

elemvalue = elem.getAttribute("ID")

</script>
Nov 11 '05 #1
2 16039
elem = root.getElementsByTagName("Product")

elemvalue = elem.item(0).getAttribute("ID")

"Jim Mitchell" <ji**********@mindspring.com> wrote in message
news:ea**************@TK2MSFTNGP09.phx.gbl...
I am getting an error...

elem is null or not an object using the following Client side javascript.

Can someone give me some help? Thanks in advance.

<XML ID="PB">
<ProductItem>
<Product ID="Adhesive">
<ItemType>Machine</ItemType>
</Product>
</ProductItem>
</XML>

<script language=javascript>

var root = new ActiveXObject("Microsoft.XMLDOM")
var xmldoc = new ActiveXObject("Microsoft.XMLDOM")
xmldoc.async = false;
xmldoc = document.getElementById("PB")
root = xmldoc.documentElement;

elem = root.getElementsByTagName("Product").item(0).docum entElement

elemvalue = elem.getAttribute("ID")

</script>

Nov 11 '05 #2
You seem to set xmldoc to an ActiveX object, then 2 lines below that,
you remove the reference to the object by redeclaring xmldoc as
document.getElementById("PB") which probably refers then to your HTML
document rather than the xmldoc you thought you had instantiated. Was
that an intentional error ?

HTH
Neil.

On Thu, 21 Aug 2003 14:42:23 -0400, "Jim Mitchell"
<ji**********@mindspring.com> wrote:
I am getting an error...

elem is null or not an object using the following Client side javascript.

Can someone give me some help? Thanks in advance.

<XML ID="PB">
<ProductItem>
<Product ID="Adhesive">
<ItemType>Machine</ItemType>
</Product>
</ProductItem>
</XML>

<script language=javascript>

var root = new ActiveXObject("Microsoft.XMLDOM")
var xmldoc = new ActiveXObject("Microsoft.XMLDOM")
xmldoc.async = false;
xmldoc = document.getElementById("PB")
root = xmldoc.documentElement;

elem = root.getElementsByTagName("Product").item(0).docum entElement

elemvalue = elem.getAttribute("ID")

</script>


================================================== ======
CaptionKit http://www.captionkit.com : Produce subtitled
internet media, transcripts and searchable video. Supports
Real Player, Quicktime and Windows Media Player.

VideoChat with friends online, get Freshly Toasted every
day at http://www.fresh-toast.net : NetMeeting solutions
for a connected world.
Nov 11 '05 #3

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

Similar topics

13
by: Dan R Brown | last post by:
I have a large form that is generated dynamically in a jsp using xml / xslt. So, to break up this form into several "tabbed" sections, I break up the form using <div> tags. Each <div...
1
by: Will | last post by:
Hi, I have a problem trying to validate dynamically created html form elements using javascript. I have dynamically created a check box using ASP for each record in a recordset and have given each...
2
by: thomasamillergoogle | last post by:
Hi, As you can see from the code below I have a simple js function called getFormElementsinTableRow(rowName). rowName is the ID of the tableRow. I just want to use js to find the child ID's of all...
5
by: Dani | last post by:
Hello everybody, I have some code that disables form elements on body load, but I notice when I hit the "back" button, I need to re-enable the form elements (that is done by clicking on a radial...
1
by: Spartanicus | last post by:
I'm pondering what the various drawbacks are of the methods to code UI elements who's function relies on javascript and css. Currently on http://www.pan-europe.utvinternet.ie/ I use styled <a>...
8
by: wASP | last post by:
Hi, I'm having a problem referencing the elements within an object after a method of that object (a member function) has been activated with an onsubmit handler: - - - - - - - - ...
24
by: RyanTaylor | last post by:
I have a final coming up later this week in my beginning Java class and my prof has decided to give us possible Javascript code we may have to write. Problem is, we didn't really cover JS and what...
4
by: Claudio Calboni | last post by:
Hello folks, I'm having some performance issues with the client-side part of my application. Basically, it renders a huge HTML table (about 20'000 cells in my testing scenario), without content....
4
by: Beagle804 | last post by:
OK. I'm very new to Javascript and what I've learned so far has been find snippets of code on the web and using them in my php programs. I put together an application that allows a Reset button to...
4
by: Norman | last post by:
I am trying to find a way to implement something like: <FORM name='form1'><TABLE> server scripting loop (php), generates X (a variable number) lines with the 3 fields { <TR><TD><input...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.