Solved

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

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

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ASP sending two datas 2 28
Selenium and Xpath 4 65
Table header must be on top 2 53
Load XML element 3 41
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

739 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