Solved

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

Posted on 2011-09-07
4
279 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
  • 2
4 Comments
 
LVL 52

Assisted Solution

by:Scott Fell, EE MVE
Scott Fell,  EE MVE earned 50 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
I was able to adapt the code easily...
That was my intended goal :)

Regards,
Hielo
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

728 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now