R
Rob Meade
Hi all,
I went on an XML course over a year ago and have finally
got around to having a use for it, but do you think I can
actually remember anything - nope!..
Ok, here's what I want to do - I want to store an XML
file with several elements that contain data for
applications we've written - its going to be used by
people in our team as a portfolio to show people when
discussing our services. They will visit an ASP page
which will read in the XML and display it in my format to
the page.
XML File structure -
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="portfolio.xsl"?>
<portfolio>
<application>
<title></title>
<image></image>
<text>text>
<livesite></livesite>
<demosite></demosite>
<projectsite></projectsite>
</application>
</portfolio>
There will be about 12 or more of the <application>
elements within the <portfolio> root element.
The ASP I had written (or some of to keep it simple) is
below :
<%
Dim RS
Set RS = Server.CreateObject("ADODB.RecordSet")
RS.ActiveConnection = "Provider=MSDAOSP; Data
Source=MSXML2.DSOControl.2.6;"
RS.Open(Server.MapPath("portfolio.xml"))
Count = 0
Do While Not RS.EOF
strApplicationTitle = ""
strApplicationImageSmall = ""
strApplicationText = ""
strApplicationLiveSite = ""
strApplicationDemoSite = ""
strApplicationProjectSite = ""
strApplicationTitle = RS(0)
strApplicationImageSmall = RS(1)
strApplicationText = RS(2)
strApplicationLiveSite = RS(3)
strApplicationDemoSite = RS(4)
strApplicationProjectSite = RS(5)
RS.MoveNext
Loop
%>
Within the loop I also run a couple of checks for the
values in the variables, and obviously display the
information to the page - I've left this out due to the
numerous lines of code / html etc...
I was running this quite successfully, but when I started
entering the 'real' information, where I needed to say
start a new paragraph I had entered :
<br/><br/>
When it iterates through the recordset it assumes
(rightly) that this is the next item it should be reading
in - then errors are generated. I do not know before
hand how many <br/>'s or other tags (list items are
another good example) will be embedded within the <text>
element - but there will be some.
Therefore I need a method of reading through the specific
elements that I require, in this case the following :
<title>
<image>
<text>
<livesite>
<demosite>
<projectsite>
If there are other tags within these I do not need them
read as XML as such, but they still need to operate
correctly when the HTML is produced on the page.
I seem to remember something about the XML DOM being able
to do this but have no recollection of how to use it.
My other thought was that I could change the inner tags
within <text> (ie <br/> ) to [br] and then just use the
replace method before going to the page - this would then
allow the XML to be read into the recordset correctly.
Any help in this matter would be appreciated.
Thanks in advance for any/all help,
Regards
Rob
PS: Using the MS site for posting this news item so I
hope it makes it through ok (first time I've tried
posting this way).
I went on an XML course over a year ago and have finally
got around to having a use for it, but do you think I can
actually remember anything - nope!..
Ok, here's what I want to do - I want to store an XML
file with several elements that contain data for
applications we've written - its going to be used by
people in our team as a portfolio to show people when
discussing our services. They will visit an ASP page
which will read in the XML and display it in my format to
the page.
XML File structure -
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="portfolio.xsl"?>
<portfolio>
<application>
<title></title>
<image></image>
<text>text>
<livesite></livesite>
<demosite></demosite>
<projectsite></projectsite>
</application>
</portfolio>
There will be about 12 or more of the <application>
elements within the <portfolio> root element.
The ASP I had written (or some of to keep it simple) is
below :
<%
Dim RS
Set RS = Server.CreateObject("ADODB.RecordSet")
RS.ActiveConnection = "Provider=MSDAOSP; Data
Source=MSXML2.DSOControl.2.6;"
RS.Open(Server.MapPath("portfolio.xml"))
Count = 0
Do While Not RS.EOF
strApplicationTitle = ""
strApplicationImageSmall = ""
strApplicationText = ""
strApplicationLiveSite = ""
strApplicationDemoSite = ""
strApplicationProjectSite = ""
strApplicationTitle = RS(0)
strApplicationImageSmall = RS(1)
strApplicationText = RS(2)
strApplicationLiveSite = RS(3)
strApplicationDemoSite = RS(4)
strApplicationProjectSite = RS(5)
RS.MoveNext
Loop
%>
Within the loop I also run a couple of checks for the
values in the variables, and obviously display the
information to the page - I've left this out due to the
numerous lines of code / html etc...
I was running this quite successfully, but when I started
entering the 'real' information, where I needed to say
start a new paragraph I had entered :
<br/><br/>
When it iterates through the recordset it assumes
(rightly) that this is the next item it should be reading
in - then errors are generated. I do not know before
hand how many <br/>'s or other tags (list items are
another good example) will be embedded within the <text>
element - but there will be some.
Therefore I need a method of reading through the specific
elements that I require, in this case the following :
<title>
<image>
<text>
<livesite>
<demosite>
<projectsite>
If there are other tags within these I do not need them
read as XML as such, but they still need to operate
correctly when the HTML is produced on the page.
I seem to remember something about the XML DOM being able
to do this but have no recollection of how to use it.
My other thought was that I could change the inner tags
within <text> (ie <br/> ) to [br] and then just use the
replace method before going to the page - this would then
allow the XML to be read into the recordset correctly.
Any help in this matter would be appreciated.
Thanks in advance for any/all help,
Regards
Rob
PS: Using the MS site for posting this news item so I
hope it makes it through ok (first time I've tried
posting this way).