• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Converting an XML document to HTML using Javascript and HTML

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I need to convert an XML document to HTML using Javascript and HTML?
Could any of you point me in the right direction?

Thanks
Alex
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well you could use XSLT and not use HTML and JavaScript.

How are you getting the XML Document, through Ajax?

Eric
 
solomon alexander
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My requirement is to keep the XML file locally in my machine.
Then to use javascript to load the XML and search for a text field and display the record in HTML
Could you point me in the right direction?

Solomon
 
Ranch Hand
Posts: 608
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Eric is right you might XSLT to work out fine for you requirements.

Read up -> http://www.w3schools.com/xsl/xsl_client.asp
More information on XSLT --> http://www.w3schools.com/xsl/

HTH
 
solomon alexander
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I got your point.
But to be more precise on what I am looking for.
I will have an HTML form having 3 fields : Title , Artist and Country.
When I enter data into these fields , it should search against the XML and display into the screen.
I am doing some proof of concept on this, meanwhile if you guys have any hint, please provide.


Thanks
Solomon
 
Eric Pascarello
author
Posts: 15385
6
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JavaScript can not read local XML files do to security restrictions. The file has to live on the server for it to be read.

Eric
 
solomon alexander
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Please find below the code to perform the task:





I m able to read an xml file using javascript, now in the process of refining the filter.
Please let me know,if i m doin anything wrong.

Solomon
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
document.all is a MAJOR NO NO. That is depreciated IE only code and will fail in any browser other than IE.

Also when you post code, please use code tags so it is readable.

Eric
 
solomon alexander
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Please see the below XSLT code:



Could you let me know, how can i perform a search based on criteria. In other words, I want to filter data dynamically based on form data.
Any Hint would be highly appreciated.

Thanks
Solomon
 
solomon alexander
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Could any of you point me in the right direction?

Thanks
Solomon
 
Sheriff
Posts: 67754
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please read this.
 
solomon alexander
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Could anyone point me in the right direction?

Solomon
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic