472,129 Members | 1,638 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,129 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 7312
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
983 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
983 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

Post your reply

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

Similar topics

2 posts views Thread by Miguel Dias Moura | last post: by
kestrel
2 posts views Thread by kestrel | last post: by
2 posts views Thread by laredotornado | last post: by
2 posts views Thread by laredotornado | last post: by
2 posts views Thread by gert | last post: by
8 posts views Thread by AKS | last post: by
5 posts views Thread by laredotornado | last post: by
reply views Thread by leo001 | last post: by

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.