?
Solved

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

Posted on 2011-09-07
4
Medium Priority
?
315 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 54

Assisted Solution

by:Scott Fell, EE MVE
Scott Fell,  EE MVE earned 200 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 1800 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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…
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

850 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