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

How do I get this value?

80
Hello :D

Im getting into trouple with this one. Do anybody know how to extract the ID (<product id="506343242">) in this XML file?

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <products xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="oemPriceXMLList.xsd">
  3.  
  4. <group name="">
  5. </group>
  6. <group name="Some Soft">
  7. <product id="506343242">
  8. <name>Adobe Acrbobat 9</name>
  9. <stock>Yes</stock>
  10. <weight>0.5</weight>
  11. <model>6504543534</model>
  12. <shortDescription>DESCRIPTION</shortDescription>
  13. <manufacturerName>Adobe</manufacturerName>
  14. <manufacturerURL>http://www.adobe.com/</manufacturerURL>
  15. <price>300</price>
I can retrieve the other values by using xmlDOC.documentElement.selectNodes("//products/group/product/stock")

I am using xmlDOC in an ASP script..

Thanks!
Sep 13 '10 #1

✓ answered by Pheddy

So I found the answer!

Here it is:

Expand|Select|Wrap|Line Numbers
  1.   Set objNodeList8    = xmlDOC.documentElement.selectNodes("//products/group/product/@id")
  2.     Response.Write objNodeList8(i).text & "<br>"
Thanks for all replies!

-Frederik

9 7526
mzmishra
390 Expert 256MB
xmlDoc.getElementsByTagName("product ")[0].getAttribute("id")
Sep 13 '10 #2
Pheddy
80
I got this error when using
Expand|Select|Wrap|Line Numbers
  1. objNodeList9 = xmlDoc.getElementsByTagName("product")[0].getAttribute("id")
Expand|Select|Wrap|Line Numbers
  1. Microsoft VBScript compilation error '800a0401' 
  2.  
  3. Expected end of statement 
  4.  
  5. /xml.asp, line 42 
  6.  
  7. Set objNodeList9 = xmlDoc.getElementsByTagName("product")[0].getAttribute("id")
  8.  
  9.  
So I tried:

Expand|Select|Wrap|Line Numbers
  1. xmlDoc.getElementsByTagName("product").getAttribute("id")
But got this error

Expand|Select|Wrap|Line Numbers
  1. Microsoft VBScript runtime error '800a01b6' 
  2.  
  3. Object doesn't support this property or method: 'getAttribute' 
  4.  
  5. /xml.asp, line 42 
  6.  
Sep 13 '10 #3
Oralloy
988 Expert 512MB
This is gonna sound dumb, but are you missing a semicolon or other statement terminator?

Also, in VBA, which is what I'm familiar with, the appropriate verb is "Let" for value assignment - "Set" is used for object assignment.
Sep 13 '10 #4
Pheddy
80
.. No I cant find any of those error, maybe my version is somewhat wrong?

I am using (in ASP)

Expand|Select|Wrap|Line Numbers
  1. Set HTTP         = CreateObject("MSXML2.XMLHTTP")
  2. Set xmlDOC        = CreateObject("MSXML.DOMDocument")
Sep 14 '10 #5
Oralloy
988 Expert 512MB
Did you try using Let, not Set?

Expand|Select|Wrap|Line Numbers
  1. Let objNodeList9 = xmlDoc.getElementsByTagName("product")[0].getAttribute("id")
Sep 14 '10 #6
Pheddy
80
That dosnt work.. Anyother bids??
Sep 14 '10 #7
jkmyoung
2,057 Expert 2GB
What version of ASP?

xmlDoc.SelectNodes("product/@id") OR
xmlDoc.SelectSingleNode("product/@id")
Sep 14 '10 #8
Pheddy
80
I am using Classic Asp.

Again I Get errors...

With

Expand|Select|Wrap|Line Numbers
  1.   Set objNodeList9    = xmlDoc.SelectSingleNode("product/@id")
  2.     Response.Write objNodeList9(i).nodeValue & "<br>"
I get:

Expand|Select|Wrap|Line Numbers
  1. Microsoft VBScript runtime error '800a000d' 
  2.  
  3. Type mismatch 
  4.  
And with

Expand|Select|Wrap|Line Numbers
  1.   Set objNodeList9    = xmlDoc.SelectNodes("product/@id")
  2.     Response.Write objNodeList9(i).nodeValue & "<br>"
I get:

Expand|Select|Wrap|Line Numbers
  1. Microsoft VBScript runtime error '800a01a8' 
  2.  
  3. Object required: '[object]' 
  4.  
Sep 14 '10 #9
Pheddy
80
So I found the answer!

Here it is:

Expand|Select|Wrap|Line Numbers
  1.   Set objNodeList8    = xmlDOC.documentElement.selectNodes("//products/group/product/@id")
  2.     Response.Write objNodeList8(i).text & "<br>"
Thanks for all replies!

-Frederik
Sep 15 '10 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Miguel Dias Moura | last post by:
Hello, I have a dataset (users) on an ASP.NET/VB page (detail.aspx). A record on this dataset (users) has 3 fields: "id", "username", "visits". The page detail.aspx is called with a...
7
by: Jim Carlock | last post by:
Does a SELECT element (listbox) need to be inside a FORM element? The code I'm playing with: <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"...
2
kestrel
by: kestrel | last post by:
i had it a while ago, but i forgot... heres what i have.<input type="button" value="Submit" onclick="this.disabled=1; this.value=Sending;"> i can get the button to disable, but the value wont...
2
by: laredotornado | last post by:
Hi, I'm having trouble with preg_match. I want to get the value in parenthese from this pattern $pattern = "/ab(.*)cde/"; $str = "abxyzcde"; What preg_match expression would i have to...
2
by: laredotornado | last post by:
Hi, Let's assume for a moment that I have well-formed HTML. I have a couple of places where I would like to extract the value of the node <td class="sidebarText" id="title1">My cell...
2
by: gert | last post by:
Can you replace this->value with *this.value in c ?
3
by: priyanka1915 | last post by:
Situation is : i got output like open=4324= volumn=435.456, change=56, etc... now i want to enter this value in table and this value updates after 3 sec and it should also update in dat table
8
by: AKS | last post by:
Hi! Here's a small test case (for Firefox): var o = { p: { func: function () {}, }, test: function () { var msg = ; var d = new Date;
5
by: laredotornado | last post by:
Hi, On my HTML page, I have a number of SPANs like <span class="myNumber">3</span> What I would like is a way to return the maximum number in between the SPANs. You can assume that if I...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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.