473,287 Members | 2,263 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,287 software developers and data experts.

Display image on HTML page using XML

143 100+
I have this product catalog. I am to scroll through the catalog on the HTML page and use data from the XML page to display the different products with a picture of each. I have the data and the scoll functions working great, but I can't tie my pictures to the products. Here's what I have so far:


HTML part:
[HTML]<body>


<xml id="product_cat" src="products.xml"></xml>


<table border="6" bordercolordark="green" bordercolorlight="#CCCCFF" cellpadding="2">

<tr><td rowspan="5" align="center" width="110" bgcolor="#CCCCFF">
<img datasrc="#product_cat" datafld="Photo"><br>
<span datasrc="#product_cat" datafld="Name"></span>
</td>
<td width="120" bgcolor="green">
<span class="rowhead">Part Number:</span>
</td>
<td width="240" bgcolor="white">
<span datasrc="#product_cat" datafld="CPN"></span>
</td>
</tr>
</table>
</body>
[/HTML]

Here's the XML file:

[HTML]<?xml version="1.0" encoding="utf-8" ?>

<CATALOG>



<PROD>
<CPN>TAB1015-10</CPN>
<NAME>Vented Pull Tabs</NAME>
<DESC>These pull tabs are vented.</DESC>
<PRICE>5.00</PRICE>
<HANDLING>0.20</HANDLING>
<Photo><img url="images/VentedPullTabs.jpg" /></Photo>
</PROD>
</CATALOG>[/HTML]



I think the problem is with the <Photo><img url="images/VentedPullTabs.jpg" /></Photo> line in the XML file.

Any Ideas?
Oct 3 '07 #1
5 13621
Dököll
2,364 Expert 2GB
I have this product catalog. I am to scroll through the catalog on the HTML page and use data from the XML page to display the different products with a picture of each. I have the data and the scoll functions working great, but I can't tie my pictures to the products. Here's what I have so far:

Any Ideas?
How about this teddarr!

See if below can be salvaged. Perhaps using img src will do the trick for you:

[HTML]

<a href="index.htm">
<img border="0" src="images/VentedPullTabs.jpg" />
</a>
[/HTML]

Let us know if that works...Welcome!
Oct 4 '07 #2
jkmyoung
2,057 Expert 2GB
I see you're using xml data islands.

I don't know if that ever worked with images, especially when the src url is embedded in another node.

To be honest, Xml Data Islands are only supported by IE, and are being phased out. I would suggest that you consider switching to XSL, or another alternative that works cross-browser.
Oct 4 '07 #3
teddarr
143 100+
In the real world I would consider this, but in the class I am taking, data islands is required for step 1. The professor did warn us not to get upset if the data islands wouldn't work for firefox.

Step 2 uses XSL as part of a search function.
Oct 4 '07 #4
jkmyoung
2,057 Expert 2GB
1st guess then: change path:
<Photo><img url="images/VentedPullTabs.jpg" /></Photo>
<img datasrc="#product_cat" datafld="Photo/img/@url"><br>

2nd guess: use entire data field seperately.
<Photo><span datasrc="#product_cat" datafld="Photo"/></Photo>

Personally doubt either of these work. Haven't used data islands in years.
Oct 4 '07 #5
teddarr
143 100+
OK, Here's what finally worked

In the HTML page:

[HTML]<table border="6" bordercolordark="green" bordercolorlight="#CCCCFF" cellpadding="2">

<tr><td rowspan="5" align="center" width="110" bgcolor="#CCCCFF">
<img datasrc="#product_cat" datafld="graphic" alt="product" height="100px" width="100px">
<span datasrc="#product_cat" datafld="Name"></span>

</td>
<td width="120" bgcolor="green">
<span class="rowhead">Part Number:</span>
</td>
<td width="240" bgcolor="white">
<span datasrc="#product_cat" datafld="CPN"></span>
</td>
</tr> [/HTML]

In the XML page:

[HTML]<PROD>
<CPN>TAB1015-10</CPN>
<NAME>Vented Pull Tabs</NAME>
<DESC>These pull tabs are vented.</DESC>
<PRICE>5.00</PRICE>
<HANDLING>0.20</HANDLING>
<graphic>images/VentedPullTabs.jpg</graphic>
</PROD>[/HTML]

Now the next problem:

On an XSL file, I take in a product name as a search string in a text box. I press the search button. Then the xslProc.output property will not display in the document.write(xslProc.output) statement. Everything works good down to the alert box that is commented out, and for a brief second, I can see that the output property does hold what I am looking for. But then it goes null.

Here's what I have so far:

[HTML]function Button1_onclick() {
var xslt = new ActiveXObject("Msxml2.XSLTemplate");
var xslDoc = new ActiveXObject("Msxml2.FreeThreadedDOMDocument");
var xslProc;
var txtsearch = form1.Text1.value;
xslDoc.async = false;
xslDoc.resolveExternals = false;
xslDoc.load("search.xsl");
xslt.stylesheet = xslDoc;
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument");
xmlDoc.async = false;
xmlDoc.resolveExternals = false;
xmlDoc.load("products.xml");
xslProc = xslt.createProcessor();
xslProc.input = xmlDoc;
// alert(form1.Text1.value);
xslProc.addParameter("NAME",txtsearch);
xslProc.transform();
document.write(xslProc.output);
}[/HTML]
Oct 5 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

23
by: Mat | last post by:
<div id="container"> <div id="main"> <div id="header"> <p class="Address">123 Fake Street, </p> <p class="City">Crazy City, </p> <p class="Province">Ontario </p> <p class="PostalCode">H0H...
5
by: Victor | last post by:
Hi I need to open an html file from the file system and embed that html file within my main aspx form. I have 2 questions: 1) How do I open the html file? I tried the File.open(Path, mode) didnt...
11
by: Tina | last post by:
I'm in a button clicked event on mainpage.aspx. I want to display a new webpage that has just my image, which is a jpg. I want the page to be a ..jpg not an aspx so that it will be easy for the...
3
by: Meena Desai | last post by:
Hi, In my .aspx page there are some .jpg images. When I browse the page using IE6, it goes into an infinite loop in downloading the image. No image is displayed after that. If I browse .htm page...
5
by: david | last post by:
Can I use WriteFile methods? It seems that it does not work. For example, the following code only dispay one figure. Response.WriteFile("images/image002.jpg") Response.Write("<br><p>")...
5
by: Peter Lapic | last post by:
I have to create a image web service that when it receives an imageid parameter it will return a gif image from a file that has been stored on the server. The client will be an asp.net web page...
9
by: tshad | last post by:
This was posted before but the message got messed up (all NLs were stripped out for some reason). I have 2 labels that hold the name of different images on my .aspx page. <asp:Label ID="Logo"...
1
by: amritranjan | last post by:
How to retrive image file from MS access database and display this in another JSPpage -------------------------------------------------------------------------------- This is my Jsp code for...
2
by: Tim Streater | last post by:
The following test page is intended to allow the user to choose an image file, and then display it. It works as expected in Safari 3.1.1, FF 2.0.0.14 (Mac), and IE7 (XP). But, it fails in FF...
3
by: =?Utf-8?B?QmlsbHkgWmhhbmc=?= | last post by:
I have a asp.net app, in the page there is a scan activex which could scan and save a jpg file in client harddisk. How could we access and display this jpg file on the fly using js in the client...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
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: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
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...
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: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.