473,386 Members | 2,050 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

XML formatting to HTML...beginner question

Hi, I apologize if I am posting this in the wrong forum. I am creating
a .net 2.0 website using vb.net. I have an XML file with the following
general format:

<LearningObjectives>
<lo number = '1'>
<Title>First Learning Objective. Click for more details</Title>
<details>These are the details for LO 1</details>
</lo>
<lo number = '2'>
<Title>Second Learning Objective. Click for more details</Title>
<details>These are the details for LO 2</details>
</lo>
<lo number = '3'>
<Title>Third Learning Objective. Click for more details</Title>
<details>These are the details for LO 3</details>
</lo>
</LearningObjectives>

I want to load in this xml file and create an HTML file built around
this data (but formatted) such that when the page first loads, only the
text in the title nodes are shown (will appear as headers), but after
each title there is some sort of link,button, or symbol that the user
can click so that after clicked, beneath the title the details for that
learning objective node expand/appear. I've been doing a lot of reading
about how in .net to serve the xml as formatted html, and am
overwhelmed. There seems to be tons of ways to do it, and I;m not sure
what is best for me. If it was just a matter of formatting the XML to
appear as HTML, I could use XSL, but since I need to be able to expand
the hidden details fields, I need to use some kind of function,
probably in javascript since it needs to be on the client side. It
doesnt seem like i can combine html/javascript in a XSL file, and there
probably is an even better way to do this in .net, but I'm confused at
this point.
Thank you to anyone who can point me in the right direction!

Feb 23 '06 #1
6 1366
Start from here..
http://jenitennison.com/xslt/grouping/index.xml
Hope that helps
Patrick

<ac****@hotmail.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
Hi, I apologize if I am posting this in the wrong forum. I am creating
a .net 2.0 website using vb.net. I have an XML file with the following
general format:

<LearningObjectives>
<lo number = '1'>
<Title>First Learning Objective. Click for more details</Title>
<details>These are the details for LO 1</details>
</lo>
<lo number = '2'>
<Title>Second Learning Objective. Click for more details</Title>
<details>These are the details for LO 2</details>
</lo>
<lo number = '3'>
<Title>Third Learning Objective. Click for more details</Title>
<details>These are the details for LO 3</details>
</lo>
</LearningObjectives>

I want to load in this xml file and create an HTML file built around
this data (but formatted) such that when the page first loads, only the
text in the title nodes are shown (will appear as headers), but after
each title there is some sort of link,button, or symbol that the user
can click so that after clicked, beneath the title the details for that
learning objective node expand/appear. I've been doing a lot of reading
about how in .net to serve the xml as formatted html, and am
overwhelmed. There seems to be tons of ways to do it, and I;m not sure
what is best for me. If it was just a matter of formatting the XML to
appear as HTML, I could use XSL, but since I need to be able to expand
the hidden details fields, I need to use some kind of function,
probably in javascript since it needs to be on the client side. It
doesnt seem like i can combine html/javascript in a XSL file, and there
probably is an even better way to do this in .net, but I'm confused at
this point.
Thank you to anyone who can point me in the right direction!

Feb 24 '06 #2
Hi Patrick,

Thanks for the reply. I don't think what they talk about on that page
applies to my situation,but I appreciate the help. They talk about
grouping transformations. I'm trying to read in a xml file, format the
data and to html, add in some client javascript functions, and send
that to the client.

Feb 24 '06 #3
In VB.NET WebForms do the following:

Drag an XML control onto the screen.
We'll assume the default name "Xml1"

I'm going to assume your XML is in a file called
"LearningObjectives.xml" & that you have an XSLT file called
"MyOutput.xslt"

Based on this you will need 2 properties assigned on the Xml1 control
..DocumentSource & .TransformSource

XML1.DocumentSource = <<path to LearningObjectives xml file>>
XML1.TransformSource = <<path to MyOutput xslt file>

And the code for the MyOutput.xslt is as follows:
===========================================
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fn="http://www.w3.org/2005/02/xpath-functions"
xmlns:xdt="http://www.w3.org/2005/02/xpath-datatypes">

<xsl:output method="html" />

<xsl:template match="/">
<HTML>
<head>
<LINK href="Styles.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript">

function switchMenu(obj) {
var el = document.getElementById(obj);
if ( el.style.display != "none" ) {
el.style.display = 'none';
}
else {
el.style.display = '';
}
}
</script>
</head>

<BODY>
<h3>OUTPUT</h3>
<xsl:apply-templates select="LearningObjectives"/>
</BODY>

</HTML>
</xsl:template>

<xsl:template match="LearningObjectives">
<xsl:comment>
//
================================================== ====================================
// Match the lo nodes
//
================================================== ====================================
</xsl:comment>
<table border="1">
<xsl:for-each select="lo">

<tr>
<td><xsl:value-of select="Title"/></td>
<td>
<div >
<!--a onclick="switchMenu('id');">Switch it now</a-->

<a>
<xsl:attribute name="value"><xsl:value-of
select="@number"/></xsl:attribute>
<xsl:attribute name="onclick">switchMenu(value);</xsl:attribute>
+/-</a>
<div>
<xsl:attribute name="id"><xsl:value-of
select="@number"/></xsl:attribute>
<xsl:value-of select="details"/>
</div>
</div>
</td>

</tr>

</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>
===========================================

Feb 24 '06 #4
Andy,

I havent quite addressed the issue of collapsing all the div areas On
Page Load.

This site may help:
http://www.dustindiaz.com/dhtml-expa...apse-div-menu/

Dickster

Feb 24 '06 #5
Hi Dickster,

Thanks a ton for your help...I'm still playing around and trying to
digest xsl in general, but I think this will do it it...Thanks!

Andy

Feb 25 '06 #6
Hi Dickster,

Everything's working great, only thing I'm stuck on is what you alluded
to, collapsing all the div areas on page load. I've tried following the
examples on your web page, but no luck, the one on the page has
statically named div tags, mine will be dynamic and I would like to be
able to close all div tags of a certain class, i.e. collapse all <div
class='details'> sections. I also tried to use display:none in the
style sheet, while this works, it stays permanently closed even when I
click the button to expand. Any advice? Thanks!

Feb 25 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

163
by: Shiperton Henethe | last post by:
Hi Know any good utilities to help me strip out the tags that Microsoft Excel 2002 leaved behind when you try and export an HTML format file? This is driving me NUTS. And really makes me...
12
by: Jacob Crossley | last post by:
Please tell me there is a way to prevent this annoyance ; - ) I'm into writing perfectly indented html, but the .net dev environment is being overzealous and messing up my html formatting. for...
10
by: Coleen | last post by:
Hi all :-) I have a weird formatting problem with an HTML table that I am populating using VB.Net and HTML. Here is the snippet of code for the cell I'm trying to format: Dim...
9
by: sck10 | last post by:
Hello, I have a page with an ImageButton that is used to redirect to another page. When the page first opens, everything looks as expected. However, when I click on the image, the new page...
4
by: Ken Wigle | last post by:
All, I would be very grateful for any help on this question. I have an application in asp.net 2.0 where I dynamically create a datatable and then bind that to a gridview. Unfortunately, the...
6
by: Glen | last post by:
Hello again, I don't blame anyone for not answering my last post, since I obviously hadn't spent much time researching, but I've come a little ways and have another question. How can I better...
8
by: SMERSH009 | last post by:
Hi All. Let's say I have some badly formatted text called doc: doc= """ friendid Female 23 years old
12
by: =?Utf-8?B?Qi4gQ2hlcm5pY2s=?= | last post by:
I'm doing a web app in VB/Dot Net 2.0. I'm probably a bit rusty and I have no experience using the repeater control. I have a user control I've created with multiple properties. I've created a...
6
by: pteare | last post by:
Hello, I am using access 07 and have some VBA code which puts some text into a memo field for me. It gets the text from various columns of a table. Currently it looks like the below: phil -...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.