Solved

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

Posted on 2011-09-07
4
291 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
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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
IP API - need data... 4 27
XML SQL 8 27
FileUp - Classic ASP 5 20
Index on a Table 6 25
The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

828 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