473,322 Members | 1,493 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,322 software developers and data experts.

Display XML Data in ASPX

Hi, I want to display some pretty basic xml data in
a .NET user control that I would like to build for my
site.

I am getting the XML from a URL that has been provided to
me (i.e. http://domain.com/somelink.asp). If I type the
URL into my browser, the xml doc below is displayed. How
can I incorporate the XML into the user control so that I
can display the company name on my web page?

The XML doc looks like this:
<companies>
<company ID="1" Name="ABC Company"/>
<company ID="2" Name="XYZ Company"/>
<companies>

Thanks for your help.
Nov 19 '05 #1
3 1926
Probably the easy way is to load into DataSet using ReadXml method and bind
the DataSet to the user control.

"Michelle" wrote:
Hi, I want to display some pretty basic xml data in
a .NET user control that I would like to build for my
site.

I am getting the XML from a URL that has been provided to
me (i.e. http://domain.com/somelink.asp). If I type the
URL into my browser, the xml doc below is displayed. How
can I incorporate the XML into the user control so that I
can display the company name on my web page?

The XML doc looks like this:
<companies>
<company ID="1" Name="ABC Company"/>
<company ID="2" Name="XYZ Company"/>
<companies>

Thanks for your help.

Nov 19 '05 #2
Michelle,

Try using the System.Web.UI.WebControls.Xml control. Drop the control onto
your web form or user control and set the "DocumentSource" to the url of your
xml data. Then set the "TransformSource" property to the url of an XSLT file.
When you run your page the Xml control will perform a transformation and
display your xml data. I've written a simple XSLT sample here that you can
test with:

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/companies/company">
<table border="1">
<tr>
<td>
<xsl:value-of select="@Name" />
</td>
</tr>
</table>
</xsl:template>

</xsl:stylesheet>

The XSLT transform above will produce an HTML table that displays the
company name on separate rows as shown below:

ABC Company
XYZ Company

HTH,
Jorge

"Michelle" wrote:
Hi, I want to display some pretty basic xml data in
a .NET user control that I would like to build for my
site.

I am getting the XML from a URL that has been provided to
me (i.e. http://domain.com/somelink.asp). If I type the
URL into my browser, the xml doc below is displayed. How
can I incorporate the XML into the user control so that I
can display the company name on my web page?

The XML doc looks like this:
<companies>
<company ID="1" Name="ABC Company"/>
<company ID="2" Name="XYZ Company"/>
<companies>

Thanks for your help.

Nov 19 '05 #3
Thanks Jorge, That's what I started working with. The
problem is it seems like the xml web control only allows
document sources relative to the website itself. I am
trying to access http://somesite/getcompanies.asp to
return my xml doc. I get an error:

"Invalid Map Path... A virtual path is expected"

I can't believe I am not able to retrieve an xml document
from another site. Is that true?

-----Original Message-----
Michelle,

Try using the System.Web.UI.WebControls.Xml control. Drop the control ontoyour web form or user control and set the "DocumentSource" to the url of yourxml data. Then set the "TransformSource" property to the url of an XSLT file. When you run your page the Xml control will perform a transformation anddisplay your xml data. I've written a simple XSLT sample here that you cantest with:

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/companies/company">
<table border="1">
<tr>
<td>
<xsl:value-of select="@Name" />
</td>
</tr>
</table>
</xsl:template>

</xsl:stylesheet>

The XSLT transform above will produce an HTML table that displays thecompany name on separate rows as shown below:

ABC Company
XYZ Company

HTH,
Jorge

"Michelle" wrote:
Hi, I want to display some pretty basic xml data in
a .NET user control that I would like to build for my
site.

I am getting the XML from a URL that has been provided to me (i.e. http://domain.com/somelink.asp). If I type the URL into my browser, the xml doc below is displayed. How can I incorporate the XML into the user control so that I can display the company name on my web page?

The XML doc looks like this:
<companies>
<company ID="1" Name="ABC Company"/>
<company ID="2" Name="XYZ Company"/>
<companies>

Thanks for your help.

.

Nov 19 '05 #4

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

Similar topics

0
by: Ben | last post by:
Hi, Can you display data, for example datagrid, in a "Formatted Excel Form" dynamically? I mean the data in datagrid will be display on the webpage as Full Formatted Excel like frame, different...
6
by: Mike | last post by:
I need to display data in text boxes not datagrid, can anyone point to some examples on how this is done in VB.NET? in the old way it was <input type="text" value=<% dataitem %> > how can i do...
2
by: Joe | last post by:
Hi, I have an asp.net script that connects to MS Access database and displays data in a table. For some reason I am do not know how to display data say in ascending order of column1. I have...
1
by: basulasz | last post by:
May be it is a bit easy question but i don't know the way to display data in bounded colums. I get data from DB with a datareader, and I want to display them on bounded colums. I dont want to...
5
by: yma | last post by:
Hello, I tried to display a column in MS Access 2000 nwind.mdb using 3 data controls. But I got "It is already opened exclusively by another user, or you need permission to view its data." I...
1
by: anoop | last post by:
hello, how can I display data from a Data source such as SQL Server in a textbox by using the click of a Button on an .aspx page in a Visual Basic ..Net Project . If I have to use a DataSet, then...
4
by: seth_hickel | last post by:
With other solutions I would get a recordset, read each record and display data by formating my html as I wanted to display values of each record. I am trying to display data in a three column...
1
by: geeteshss | last post by:
First i would like to thank those persons who helped me out in solving my earlier problems the present problem is that i am unable to display data in datagrid....... but the data is visible in...
7
by: nma | last post by:
Hi I'm trying to display data in a table list format but error message like this appear. What is wrong with the code? "Parse error: syntax error, unexpected '<' in C:\htdocs\...\MB2movieinfo.php...
4
by: JuAn2226 | last post by:
Hi, can anyone help me . when my program starts there is numbers and time will be display in the form of visual basic. it will run continuesly .My problem here is i dont know how to display the data...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.