Solved

Need help extracting article titles & descriptions from .XML and .INC files for article detail pages

Posted on 2011-09-07
4
296 Views
Last Modified: 2012-06-27
I'm currently maintaining a website that's coded in Classic ASP, and I need to figure out a way to exact specific bits of text from .XML and .INC files, and use them to display them as custom page titles and meta descriptions within an article detail page

Here is a link to an example article detail page:

http://www.rex3.com/view_article.asp?article_id=24

If I was working with a database of some kind, it'd be no problem for me at all.  However, the site is instead pulling data from.XML and .INC files, .. and I can't quite figure out how to interface with them and extract the data.  For example:

Title Tag = Article Title
Meta Description = First Few Sentences of Article Body

I've attached all of the relevant files (see below).

I suspect that all I need to do is find a way to interface with the file named "articles.xml", .. since it seems to contain the titles and short descriptions that I need.

article_name
<short_desc>

 If I could somehow just query the XML file using the article id value, and then display the data, I think that might do the trick.  Any help would be appreciated, .. as my ASP coding skills are pretty weak.  

Thanks!
- Yvan
view-article.txt
view-article.xsl
BAPBQUXKCK1262011124358.txt
articles.xml
0
Comment
Question by:egoselfaxis
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 52

Assisted Solution

by:Scott Fell, EE MVE
Scott Fell,  EE MVE earned 50 total points
ID: 36497144
I think you can only pull the rendered html unless you specify the actual ful url of the include file like http://www.xyz.com/includes/abc.inc ?

Have a look at this using xmlhttp  http://classicasp.aspfaq.com/general/how-do-i-read-the-contents-of-a-remote-web-page.html
0
 
LVL 82

Accepted Solution

by:
hielo earned 450 total points
ID: 36497396
try the attached code - save it as test.asp in the same folder where you have articles.xml
<%
If ""=Trim(Request.Querystring("article_id")) Then
	Response.Write "No article id was specified"
Else
	Dim filename
	filename=Server.MapPath("articles.xml")

	Set oXml=Server.CreateObject("MSXML2.DOMDocument")

	If Not oXml.load(filename) Then
        Err.Raise oXml.parseError.errorCode, oXml.parseError.line, oXml.parseError.reason
	Else
		oXml.setProperty "SelectionLanguage","XPath"
		Set nodeSet=oXml.documentElement.selectNodes("/articles/article[@id = " & Request.Querystring("article_id") & "]")
		If 0=nodeSet.length Then
			Response.Write ("No Items found for the specified article id")
		Else
			Response.write "<table border=""1"">"
			For Each node in nodeSet
				Response.write "<tr>"
				Response.write "<td>" & node.getAttribute("article_name") & "</td>"
				Response.write "<td>" & node.selectSingleNode("short_desc").text & "</td>"
				Response.write "</tr>"
			Next
			Response.write "</table>"
		End If
		Set nodeSet=Nothing
		Set oXML=Nothing
	End If
End If
%>

Open in new window

0
 

Author Closing Comment

by:egoselfaxis
ID: 36497607
Thanks so much hielo!  That's exactly what I was looking for.  I was able to adapt the code easily so that it writes in a dynamic page title and meta description tags:

-------------------------------------------------

For Each node in nodeSet
Response.write "<title>" & node.getAttribute("article_name") & "</title>" & vbCrLf
Response.write "<meta name=""Keywords"" content=""printers, commercial printing, printing companies, print shops"">" & vbCrLf                  
Response.write "<meta name=""Description"" content=""" & node.selectSingleNode("short_desc").text & """ />" & vbCrLf
Next

-------------------------------------------------

Padas -- thank you also for your providing me with the resource for xmlhttp. I trust that this will come in handy for me at some point in the future.

Thanks guys!
- Yvan
0
 
LVL 82

Expert Comment

by:hielo
ID: 36497633
I was able to adapt the code easily...
That was my intended goal :)

Regards,
Hielo
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
XML extra information 8 36
ASP and Extracting XML 7 27
Pass SQL to JSON. Page is in classic ASP and using Jquery 4 37
Boolean 13 20
Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question