mikec79
01-21-2008, 05:42 AM
Hi all from a newbie!
I hope one of you fine bods out there can help me. Please bare with me because I'm new to XML and only know the very very basics.
Anyway what I'm trying to do is refer to certain sections of an xml file to display. I've managed to achieve this with childNode elements by doing this:
XML file: ActivityXML.xml
<?xml version="1.0" encoding="UTF-8" ?>
- <dataroot xmlns:od="urn:schemas-microsoft-com:officedata">
- <tblActivityXML>
<ActCode>ASAA</ActCode>
<SellPrice>159</SellPrice>
<WebCat>Fly</WebCat>
<StrapLine>Step back in time</StrapLine>
<Experience>No previous experience or qualifications are required to take part in this activity.</Experience>
<MinAge>To participate in this activity you must be at least 14 years old.</MinAge>
</tblActivityXML>
- <tblActivityXML>
<ActCode>ASAB</ActCode>
<SellPrice>259</SellPrice>
<WebCat>Fly</WebCat>
<StrapLine>Step back in time</StrapLine>
<Experience>No previous experience or qualifications are required to take part in this activity.</Experience>
<MinAge>To participate in this activity you must be at least 14 years old.</MinAge>
</tblActivityXML>
- <tblActivityXML>
<ActCode>ASAC</ActCode>
<SellPrice>359</SellPrice>
<WebCat>Fly</WebCat>
<StrapLine>Step back in time</StrapLine>
<Experience>No previous experience or qualifications are required to take part in this activity.</Experience>
<MinAge>To participate in this activity you must be at least 14 years old.</MinAge>
</tblActivityXML>
</dataroot>
In the .asp page I use this code before the html code:
<%
Option Explicit
Response.Buffer = True
Dim xml
Set xml = Server.CreateObject("Microsoft.XMLDOM")
xml.async = False
xml.load (Server.MapPath("ActivityXML.xml"))
Dim Code, Fitness
Code = xml.documentElement.childNodes(0).childNodes(0).text
MinAge = xml.documentElement.childNodes(0).childNodes(5).text
Set xml = Nothing
%>
And to display the part I'm refering to in the xml file:
<h1 class="step3-activity-title"><%= Code$ %></h1>
<p><%= MinAge$ %></p>
Which at the moment is displaying:
<h1 class="step3-activity-title">ASAA</h1>
<p>To participate in this activity you must be at least 14 years old.</p>
This is all well and good but what I really need is a statement like if tblActivityXML.ActCode = "ASAA" I need it to then display the childNode element <MinAge> property. Is this at all possible? Or am I talking rubbish? lol
Thanks in advance for your help.
Mike
I hope one of you fine bods out there can help me. Please bare with me because I'm new to XML and only know the very very basics.
Anyway what I'm trying to do is refer to certain sections of an xml file to display. I've managed to achieve this with childNode elements by doing this:
XML file: ActivityXML.xml
<?xml version="1.0" encoding="UTF-8" ?>
- <dataroot xmlns:od="urn:schemas-microsoft-com:officedata">
- <tblActivityXML>
<ActCode>ASAA</ActCode>
<SellPrice>159</SellPrice>
<WebCat>Fly</WebCat>
<StrapLine>Step back in time</StrapLine>
<Experience>No previous experience or qualifications are required to take part in this activity.</Experience>
<MinAge>To participate in this activity you must be at least 14 years old.</MinAge>
</tblActivityXML>
- <tblActivityXML>
<ActCode>ASAB</ActCode>
<SellPrice>259</SellPrice>
<WebCat>Fly</WebCat>
<StrapLine>Step back in time</StrapLine>
<Experience>No previous experience or qualifications are required to take part in this activity.</Experience>
<MinAge>To participate in this activity you must be at least 14 years old.</MinAge>
</tblActivityXML>
- <tblActivityXML>
<ActCode>ASAC</ActCode>
<SellPrice>359</SellPrice>
<WebCat>Fly</WebCat>
<StrapLine>Step back in time</StrapLine>
<Experience>No previous experience or qualifications are required to take part in this activity.</Experience>
<MinAge>To participate in this activity you must be at least 14 years old.</MinAge>
</tblActivityXML>
</dataroot>
In the .asp page I use this code before the html code:
<%
Option Explicit
Response.Buffer = True
Dim xml
Set xml = Server.CreateObject("Microsoft.XMLDOM")
xml.async = False
xml.load (Server.MapPath("ActivityXML.xml"))
Dim Code, Fitness
Code = xml.documentElement.childNodes(0).childNodes(0).text
MinAge = xml.documentElement.childNodes(0).childNodes(5).text
Set xml = Nothing
%>
And to display the part I'm refering to in the xml file:
<h1 class="step3-activity-title"><%= Code$ %></h1>
<p><%= MinAge$ %></p>
Which at the moment is displaying:
<h1 class="step3-activity-title">ASAA</h1>
<p>To participate in this activity you must be at least 14 years old.</p>
This is all well and good but what I really need is a statement like if tblActivityXML.ActCode = "ASAA" I need it to then display the childNode element <MinAge> property. Is this at all possible? Or am I talking rubbish? lol
Thanks in advance for your help.
Mike