Any XML and ASP gurus here? Please help ...

kuk

Platinum Member
Jul 20, 2000
2,925
0
0
The original thread is over at the "Software" forum, but there isn't much movement over there. Let's see if in OT this will yield any responses.

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

I'm trying to build a XML-driven database of news articles, but I can't seem to find any info on the web. I want the XML file to be parsed on the server, and not on the client, using ASP, but I can't find the command to do this. I know it's possible ...

Here's what I have for the .xml file:

<?xml version=&quot;1.0&quot;?>
<main>

<title>News Title</title>
<author>Me</author>
<subject>Hardware</subject>
<summary>A summary of the article</summary>

<page n=&quot;_1&quot;>
<pagetitle>Introduction</pagetitle>
<text><![CDATA[Blah blah blah
<p>Insert HTML here</p]]></text>
</page>

<page n=&quot;_2&quot;>
<pagetitle>Conclusion</pagetitle>
<text><![CDATA[Blah blah blah
<p>Insert HTML here</p]]></text>
</page>

</main>



I want the .asp file to retrieve this information acording to what is asked to be done. For example, retrieve just the Title, Author and the contents of Page 2, and place them inside variables, that would latter be written as <% response.write(Title) %>.

Anyone care to help ? :eek:
 

Bluga

Banned
Nov 28, 2000
4,315
0
0

go to the bookstore and pick up &quot;Professional Active Server Pages&quot; by Wrox. In the last case study they have exactly what you need.
 

joohang

Lifer
Oct 22, 2000
12,340
1
0
Do you already know how to do it with MSXML?

All you have to do is loading Server.CreateObject the msxml.dll and use the documentElement, etc just like you would do elsewhere.

Try the following sites:
MSDN Workshop
MSDN XML section --> go to XML SDK

LMK if you want me to show you some sample code.
 

StageLeft

No Lifer
Sep 29, 2000
70,150
5
0
Here is another vote for Wrox's ASP books. I bought &quot;Beginning Active Server Pages 2.0&quot; last year and going from no skill to about 5 days later I was ASPing it up like a star (considering). The best $45 I've spent in a long time.
 

kuk

Platinum Member
Jul 20, 2000
2,925
0
0
Bluga and Skoorb (muahaha, looks like I'm talking to some Star Was creatures :D:p) .. about the book ... I don't want to spend $45 (which can even more expensive since I have to import it), just to learn the basic trick to get ASP and XML communicating. But thanks for the heads up ... :D


joohang: I've started learning XML this week, and I'm trying to understand how to get it to talk to ASP. I don't know anything about MSXML :eek:. I need just the basic basics :p. Some sample codes will be truely welcomed.
 

joohang

Lifer
Oct 22, 2000
12,340
1
0
Ditto for Wrox books, especially their ASP series.

I have the Active Server Pages 2.0 book. It's a very handy reference.

But for XML, I didn't find Wrox books very impressive. I recommend &quot;XML in Action&quot; by MSPress. It's a bit outdated, but it's actually built around examples (with IE5) rather than dragging on and on for 600 pages of theories and rules.
 

kuk

Platinum Member
Jul 20, 2000
2,925
0
0
Joohang:

OK, I understand how xml.documentElement.childNodes(0).text works, but I see it as a non-pratical way of retrieving data, since I need to know the exact position of the element inside the .xml file.

I don't know if it's possible, but an easier way of doing this would be calling the data by it's tag name, such as &quot;get me the value for pagetitle where page n=1&quot;.

Do you know if this is possible?
 

joohang

Lifer
Oct 22, 2000
12,340
1
0
kuk,

I use XPath:

i.e. xmldom.documentElement.selectSingleNode(&quot;//main/page&quot;)

Check out some articles on XPath in the XML SDK
 

StageLeft

No Lifer
Sep 29, 2000
70,150
5
0
Probably the reason I gave you a book recommendation instead of the answers is because I don't know it...I haven't used ASP in almost 2 months - its amazing how fast syntax goes down :(
 

joohang

Lifer
Oct 22, 2000
12,340
1
0
For your viewing pleasure, here's the most &quot;sophisticated&quot; XML app I've built.

I've been exposed to XML for quite some time, but I didn't really start learning it seriously until last summer. Too bad I have to go to college, or else I could be making some big bucks. :)

I am building a site called AboutFrontPage.com (FYI, I'm MS Frontpage MVP), which is a rebuild of my old Frontpage tutorial site in XML.

The following code uses MSXML 3.0 (the XML parser) and FSO to build a &quot;search&quot; function. The FSO returns a list of XML files in a folder. Then, MSXML searches for document/main/body for the keyword &quot;frontpage&quot; and returns the number of pages that contain the keyword.

<%
' XML DOM
dim xmldom : set xmldom = Server.CreateObject(&quot;MSXML2.DOMDocument&quot;)
xmldom.async = false

' File System Object
set fso = Server.CreateObject(&quot;Scripting.FileSystemObject&quot;)
set filelist = fso.GetFolder(Server.MapPath(&quot;/xml/frontpage&quot;))

dim i
i = 0

' Query through the XML documents
For each file in filelist.files
xmldom.load(Server.MapPath(&quot;xml/frontpage/&quot; &amp; file.name &amp; &quot;&quot;))
set fNode = xmldom.documentElement.selectSingleNode(&quot;//document/main/body&quot;)
if instr(lcase(fNode.text), &quot;frontpage&quot;) > 0 then
i = i + 1
end if
Next

Response.Write(i)
%>