ASP Classic - Read XML File inner content

Hello, All;

Could someone please assist me in reading the inner parts of these nodes.
I can get all the other data, just not the count and views.

ASP Script
   Set objXML = Server.CreateObject("MSXML2.DOMDocument.3.0")
   objXML.async = False
objXML.Load (Server.MapPath("test.xml"))

For Each xmlProduct In objXML.documentElement.selectNodes("/feed/entry")
     theTitle = xmlProduct.selectSingleNode("media:group/media:title").text
     theDescr = xmlProduct.selectSingleNode("media:group/media:description").text 
     Rating = xmlProduct.selectSingleNode("media:group/media:community/media:starRating[@count]").text 
     statistics = xmlProduct.selectSingleNode("media:group/media:community/media:statistics").text
	 Response.Write "<strong>"&Server.HTMLEncode(theTitle) & "</strong><br>"
	 Response.Write "<strong>"&Server.HTMLEncode(thedescr) & "</strong><br>"
	 Response.Write "<strong>"&Server.HTMLEncode(Rating) & "</strong><br>"   
	 Response.Write "<strong>"&Server.HTMLEncode(statistics) & "</strong><br><hr/>"  

Set objXML = Nothing  

Open in new window

XML Script
The two area's that I need to get the values from are
        <media:starRating count="92070"/>   (The count)
        <media:statistics views="2151299"/>  (The Views)
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns:media="" xmlns="">
      <media:title>Title Here</media:title>
      <media:description>information here</media:description>
        <media:starRating count="92070"/>
        <media:statistics views="2151299"/>

Open in new window

Thanks, All
LVL 31
Wayne BarronAuthor, Web DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Nitin SontakkeDeveloperCommented:
Shooting in pitch black dark!

Rating = xmlProduct.selectSingleNode("media:group/media:community/media:starRating")

Count = Rating.Attributes[0].text

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mccarlIT Business Systems Analyst / Software DeveloperCommented:
Try taking the square brackets out of the XPath expression...

     Rating = xmlProduct.selectSingleNode("media:group/media:community/media:starRating@count").text 

Open in new window

Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
I have a bunch of previous examples from similar questions here on ee.  See if my answer by example helps point you in the right direction.

Build an E-Commerce Site with Angular 5

Learn how to build an E-Commerce site with Angular 5, a JavaScript framework used by developers to build web, desktop, and mobile applications.

You should set the SelectionNamespaces property first:
objXML.setProperty "SelectionNamespaces", "xmlns:media=''"

Open in new window

Wayne BarronAuthor, Web DeveloperAuthor Commented:
>> Shooting in pitch black dark!
What do you mean? I provided all the source code, for you to compile together in order to give a working example for your answer.
So, why would you come in and say: Shooting in pitch black dark.
The only whay that would be true, is if I would have provided just information and no source code.
I tested out your code as well, and it gave me an error.

Expected end of statement
/test/asp/test.asp, line 10
sCount = Rating.GetAttribute[0].text

Your code gives me the following error.
Expected token 'eof' found '@'. media:group/media:community/media:starRating-->@<--count

That is fine, in the actual project, that it already set.
I am wanting to find out how to get the COUNT and the VIEWS at this moment.

I will check out the link you provided.
Wayne BarronAuthor, Web DeveloperAuthor Commented:
I looked at your code, and could not make sense of it. Sorry.

I tried this.

 set Rating = xmlProduct.selectSingleNode("media:group/media:community/media:starRating")
  sCount = Rating.Item(0).getAttribute("count")

It gives me the following error.
Object doesn't support this property or method: 'Rating.Item'

So, with the newly found knowledge from trying that.
I took the example from Nitin
And change the [] to ()
sCount = Rating.Attributes(0).text

And it worked.
I am good to go on this one.
Wayne BarronAuthor, Web DeveloperAuthor Commented:
I have to add one last thing here.
I had to SET the Variable.

     set Rating = xmlProduct.selectSingleNode("media:group/media:community/media:starRating")
	 sCount = Rating.Attributes(0).text
     set Stats = xmlProduct.selectSingleNode("media:group/media:community/media:statistics")
	 sStats = Stats.Attributes(0).text
	 Response.Write "<strong>"&Server.HTMLEncode(sCount) & "</strong><br>"   
	 Response.Write "<strong>"&Server.HTMLEncode(sStats) & "</strong><br><hr/>"  

Open in new window

Have a good one all.
Nitin SontakkeDeveloperCommented:
Shooting in pitch black dark!

NEVER EVER do I say such things to others. I say it to myself.
mccarlIT Business Systems Analyst / Software DeveloperCommented:
Sorry, I was not on my game before, you need a forward slash too...

     Rating = xmlProduct.selectSingleNode("media:group/media:community/media:starRating/@count").text 

Open in new window

Be careful with the code that you have posted, in case the there can be more than one attribute on the starRating element and "count" is not the first one.
Wayne BarronAuthor, Web DeveloperAuthor Commented:
No problem, I was able to use your code, with some tweaking.

I will test later on.
Right now, I have a working code.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.