Question

display XML in HTML

Asked by: mcrmg

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-08-21 at 06:04:26ID24671206
Topics

Extensible HTML (XHTML)

,

Extensible Stylesheet Language Transformation (XSLT)

,

Cascading Style Sheets (CSS)

,

Web Languages/Standards

Participating Experts
4
Points
500
Comments
35

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Combine HTML/XML
    I have an XML document that I would like to display with an HTML header. The XML document includes a link to a XSL StyleSheet that formats the XML data and puts it in HTML tables. I would like to put this XML inside the HTML to create a single page that can be delivered to ...
  2. HTML and XML
    Hi, What are advantages and disadvantages of HTML ? Why HTML is more popular than XML ? To user , what is the difference between of HMTL and XML ?

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: KravimirPosted on 2009-08-21 at 21:15:11ID: 25157371

That's the kind of thing that XSL is used for. I'll request that a moderator add this question to the XSL zone for you.

 

by: GertonePosted on 2009-08-22 at 04:13:32ID: 25158252

What do you have and what do you want?

I have a link to an XML document, and basically that is it
- do you need in-page javascript that gets this page?
- do you simply want this transformed into XHTML?
- do you need some .net or java code that fetches the XML and renders XHTML?

Part of the question indeed will require XSLT, but is that all you need?

 

by: GertonePosted on 2009-08-22 at 04:20:12ID: 25158272

this would be a start for an XSLT, but now you need to say what exactly you want, how in the html

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:template match="/">
        <html>
            <head/>
            <body>
                <xsl:apply-templates select="//response/results/result"/>
            </body>    
         </html>
    </xsl:template>
    
    <xsl:template match="result">
        <table>
            <tr>
                <th>zpid</th>
                <td><xsl:value-of select="zpid"/></td>
            </tr>
            <xsl:for-each select="links/*">
                <tr>
                    <th><xsl:value-of select="name()"/></th>
                    <td><xsl:value-of select="."/></td>
                </tr>
            </xsl:for-each>
        </table>
    </xsl:template>
 
</xsl:stylesheet>
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:

Select allOpen in new window

 

by: pravinasarPosted on 2009-08-22 at 04:39:19ID: 25158315

I have a generic Javascript function, which creates a HTML table from any XML file.

Check this out at

http://javascriptjournal.com/ws/?p=14

http://javascriptjournal.com/tutorials/createXmlTable.htm

 

by: GertonePosted on 2009-08-22 at 06:34:21ID: 25158635

> I have a generic Javascript function, which creates a HTML table from ANY XML file.

If I read this, I am obviously very curious.
As self-advertisment this is very nice, but the statement is soo untrue.
I was particularly interested in what you have to offer on deeply nested XML structures
... and I found nothing at all. This code handles tabular XML data, that is it, and that is not even 10% of all XML data around.
I think the "ANY" should read "AN", because it literally looks for the "BOOK" element

> var x = xmlDoc.getElementsByTagName('BOOK')

Even then I should note that the code is not up to standard modern technology,
you are using a microsoft parser, still present in the microsoft msxml.dll,
but one you should have stopped using at least 8, if not 10 years ago

>xmlDoc = new ActiveXObject("Microsoft.XMLDOM");

It is common to use msxml2 these days, not only because it is more standardised and less buggy , but more memory friendly and fast

So, be carefull if you advertise your own solutions above their value.
People that come here with questions are looking for high quality solutions, not commercials

 

by: julianmatzPosted on 2009-08-22 at 10:15:55ID: 25159430

Here's another option. You could take the XML data and output the data using PHP's SimlpeXML.

http://php.net/simplexml

 

by: mcrmgPosted on 2009-08-22 at 11:10:54ID: 25159633

As you can see in the querystring in the url I posrted, it has address, I want to know how I can display it in HTML, so it is more readable....

We are using class ASP, I want to have a form that user can enter address and return back in XHTML  thanks


thanks

 

by: GertonePosted on 2009-08-23 at 16:46:15ID: 25164787

Something like this should do the trick,
given you save my XSLT as "listing.xsl"

<% @Language = "VBScript" %>
<%
Dim oXML
Set oXML = Server.CreateObject("MSXML2.DOMDocument")
Dim oXSL
Set oXSL= Server.CreateObject("Msxml2.FreeThreadedDOMDocument")
Dim oTmpl
Set oTmpl= Server.CreateObject("Msxml2.XSLTemplate")
Dim oProc
 
oXSL.async = false
oXSL.load Server.MapPath("listing.xsl")
 
oXML.validateOnParse = true
oXML.setProperty "ServerHTTPRequest", True
oXML.Load "http://www.zillow.com/webservice/GetSearchResults.htm?zws-id=X1-ZWz1c5s42gbu2z_14qhc&address=2114+Bigelow+Ave&citystatezip=Seattle%2C+WA"
 
oTmpl.stylesheet = oXSL
 
Set oProc= oTmpl.createProcessor()
oProc.input = oXML
 
oProc.output = Response
oProc.transform()
 
%>
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:

Select allOpen in new window

 

by: mcrmgPosted on 2009-08-24 at 06:20:00ID: 25167979

I tried the code above, I got a black page.  ZPID is not showing, I was wondering if you could help me with this..thaks

 

by: GertonePosted on 2009-08-24 at 06:25:02ID: 25168020

I can't debug this from a distance, or very difficult.
How much ASP experience do you have?
Can you check the objects for content
(meaning: is the XML loaded correctly, is the XSL loaded correctly, ...)

 

by: mcrmgPosted on 2009-08-24 at 06:39:16ID: 25168164

I am okay with ASP, I think the problem is with the xsl tags. (I think)
in your xsl file, it says the following, the parent tag for ZPID is RESULT, above RESULT, there are two more tags, RESULTS and RESPONSE.  I dont have much expeiense with XML..thx

 

by: GertonePosted on 2009-08-24 at 08:51:54ID: 25169547

I have an apply-templates that goes directly there, but lets make a test
change your XSLT to this one, and tell me what you see

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
    <html>
        <body>
            <h1>You can see me, don't you?</h1>
        </body>
    </html>
</xsl:template>
</xsl:stylesheet>
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:

Select allOpen in new window

 

by: mcrmgPosted on 2009-08-24 at 09:21:53ID: 25169872

I got "You can see me, don't you?" big..thx

 

by: GertonePosted on 2009-08-24 at 12:19:05ID: 25171464

OK, the code doesn't crash out, that is good and the XSLT is working.
Let us now see whether the XML is loaded correctly
Try this XSLT

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:template match="/">
        <html>
            <body>
                <h1>Here comes the root element</h1>
                <p>
                    <xsl:value-of select="name(*)"/>
                 </p>
            </body>
        </html>
    </xsl:template>
</xsl:stylesheet>
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:

Select allOpen in new window

 

by: mcrmgPosted on 2009-08-24 at 12:50:32ID: 25171784

okay, I have "Here comes the root element" big..thx

 

by: GertonePosted on 2009-08-24 at 13:24:24ID: 25172201

OK, but no name for the root element underneath that?
That means that the XML is not loaded correctly.
Can you check that?
You might need to check some references on loading XML using VBScript in ASP
(I am not a real serious ASP programmer)

I go to bed now and am not available tomorrow, I will pick up from here on wednesday

 

by: mcrmgPosted on 2009-08-25 at 05:04:52ID: 25176569

This is what I used, I dont know if I am testing the right thing.  Please help..thx

Response.Buffer = True
Dim xml
Set xml = Server.CreateObject("Microsoft.XMLDOM")
xml.async = False
xml.load("http://www.zillow.com/webservice/GetSearchResults.htm?zws-id=X1-ZWz1c5s42gbu2z_14qhc&address=2114+Bigelow+Ave&citystatezip=Seattle%2C+WA")
   If xml.parseError.errorCode <> 0 Then
      response.write "XML Error"
      response.Write ("Parse Error line " & xml.parseError.line & ", character " & _
       xml.parseError.linePos & vbCrLf & xml.parseError.srcText)
 

   else
      response.write "Good XML"
   End If

 

by: GertonePosted on 2009-08-25 at 05:09:10ID: 25176606

seems like a good test,
but you need to use a more modern XML object
Server.CreateObject("MSXML2.DOMDocument")

 

by: mcrmgPosted on 2009-08-25 at 05:27:48ID: 25176735

I received "XML ErrorParse Error line 0, character 0 "


does it mean XML is good?  thx

 

by: GertonePosted on 2009-08-25 at 05:31:05ID: 25176772

No, "Error" usually means it is not good.

There seems to be an issue loading the XML,
maybe there is an issue with the schema

 

by: mcrmgPosted on 2009-08-25 at 05:36:26ID: 25176821

I used another url to test, and still have error

http://www.zillow.com/webservice/GetZestimate.htm?zws-id=X1-ZWz1c5s42gbu2z_14qhc&zpid=48749425

If there is an issue with schema, where can I start?  thx
http://www.zillow.com/howto/api/GetZestimate.htm

 

by: GertonePosted on 2009-08-25 at 05:46:00ID: 25176905

well, they are all from the same site,
there might be a issue because of restrictions on the site.
Can you try with an XML from a completely different URL?

 

by: mcrmgPosted on 2009-08-25 at 05:53:17ID: 25176976

okay, I could not find one, so I the xml file form here
http://msdn.microsoft.com/en-us/library/ms762271(VS.85).aspx
and save it as x.xml and call it from the asp page like this, I am still getting this only, no name..thx
"Here comes the root element"

<% @Language = "VBScript" %>
<%
Dim oXML
Set oXML = Server.CreateObject("MSXML2.DOMDocument")
Dim oXSL
Set oXSL= Server.CreateObject("Msxml2.FreeThreadedDOMDocument")
Dim oTmpl
Set oTmpl= Server.CreateObject("Msxml2.XSLTemplate")
Dim oProc
 
oXSL.async = False
oXSL.load Server.MapPath("listing.xsl")
 
oXML.validateOnParse = True
oXML.setProperty "ServerHTTPRequest", True
oXML.Load "x.xml"
 
oTmpl.stylesheet = oXSL
 
Set oProc= oTmpl.createProcessor()
oProc.input = oXML
 
oProc.output = Response
oProc.transform()
 
%>

 

by: GertonePosted on 2009-08-25 at 06:05:52ID: 25177084

If you save the XML as a file, you need to load it differently
 
oXML.async = False
oXML.validateOnParse = True
oXML.load Server.MapPath("x.xml")

That is because you no longer load it from a httpserver

 

by: mcrmgPosted on 2009-08-25 at 06:20:29ID: 25177246

hmm...it works....

 

by: mcrmgPosted on 2009-08-25 at 06:28:22ID: 25177324

so you would think it is something wrong with the XSD?  thx

 

by: GertonePosted on 2009-08-25 at 06:31:05ID: 25177357

now try to download and save the zillow file,
then make a httprequest for fetching the file directly

 

by: mcrmgPosted on 2009-08-25 at 06:46:09ID: 25177518

okay, I copied and pasted it to a notepad, I deleted all the "-", and it works.....thx

 

by: GertonePosted on 2009-08-25 at 06:47:56ID: 25177542

welcome

 

by: mcrmgPosted on 2009-08-25 at 07:06:25ID: 25177717

so anyway that I can get it to work on line?  thx

 

by: GertonePosted on 2009-08-25 at 07:12:12ID: 25177771

well, our next step is to make sure that the XML is effectively loaded using this code

oXML.validateOnParse = true
oXML.setProperty "ServerHTTPRequest", True
oXML.Load "http://www.zillow.com/webservice/GetSearchResults.htm?zws-id=X1-ZWz1c5s42gbu2z_14qhc&address=2114+Bigelow+Ave&citystatezip=Seattle%2C+WA"

maybe there are restrictions.
I can't look into that right now, since I am at a customers location behind a firewall.
But why don't you ask a parallel question on the ASP track, to see if these three lines have restrictions in an ASP environment.
All what is left for us to do now is
- get the dynamic load working => ask the ASP forum for that
- change my XSLT to give you exactly what you need => come back here for that later

 

by: GertonePosted on 2009-08-25 at 07:14:45ID: 25177804

It would really be beneficial I think if you switched validation off
oXML.validateOnParse = false

 

by: mcrmgPosted on 2009-08-25 at 07:24:19ID: 25177911

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...