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/>"  
Next 

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="http://search.yahoo.com/mrss/" xmlns="http://www.w3.org/2005/Atom">
  <entry>
    <media:group>
      <media:title>Title Here</media:title>
      <media:description>information here</media:description>
      <media:community>
        <media:starRating count="92070"/>
        <media:statistics views="2151299"/>
      </media:community>
    </media:group>
  </entry>

Open in new window


Thanks, All
Carrzkiss
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
0

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

0
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.

://www.experts-exchange.com/questions/28354861/receive-XML-request-and-return-it-using-classic-ASP.html
0
Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

zc2Commented:
You should set the SelectionNamespaces property first:
objXML.setProperty "SelectionNamespaces", "xmlns:media='http://search.yahoo.com/mrss/'"

Open in new window

0
Wayne BarronAuthor, Web DeveloperAuthor Commented:
@Nitin
>> 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
-------------------------------------------^

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

@zc2
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.

@Scott.
I will check out the link you provided.
0
Wayne BarronAuthor, Web DeveloperAuthor Commented:
@Scott.
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.
0
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.
Wayne
0
Nitin SontakkeDeveloperCommented:
Shooting in pitch black dark!

NEVER EVER do I say such things to others. I say it to myself.
0
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.
0
Wayne BarronAuthor, Web DeveloperAuthor Commented:
@Nitin.
No problem, I was able to use your code, with some tweaking.

@mccarl.
I will test later on.
Right now, I have a working code.
0
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
ASP

From novice to tech pro — start learning today.