I'm new to XML, so I was wondering can someone help me to get started with it.
Basically, I have a simple HTML document:
and I have a simple XML file:Code:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>XML TESTING</title> <link type="text/css" href="jquery-ui-1.8.9.custom.css" rel="Stylesheet" /> <script type="text/javascript" src="jquery-1.4.4.min.js"></script> <script type="text/javascript" src="jquery-ui-1.8.9.custom.min.js"></script> <script type="text/javascript" src="script.js"></script> </head> <body> <p>TEXT</p> </body> </html>
I just want to connect my XML with my HTML with JavaScript (or preferably jQuery) and change the inner text of paragraph to info value of the first product. In the end, my HTML document should have a single paragraph with a text "Pioneer info" so how do I that?Code:<?xml version="1.0" encoding="utf-8"?> <products> <product> <name>Pioneer</name> <price>1400din</price> <info>Pioneer info</info> </product> <product> <name>Khan</name> <price>5400din</price> <info>Khan info</info> </product> <product> <name>Seme</name> <price>3400din</price> <info>Seme info</info> </product> </products>
Do I have to have a server to do that (I have WAMP installed on my PC so that won't be problem) or not?
Basically I just need the JS or jQuery script that can connect to XML and replace contents of a paragraph with a content from a specific element from my XML.


Reply With Quote

Bookmarks