Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

load specific content xml(xsl) into html

Posted on 2013-11-03
5
Medium Priority
?
572 Views
Last Modified: 2013-11-04
<body>

 <div id="nav">
   <ul>
      <li id="9ebae5de1075efb4699abaaf106acf57">get content</li>
   </ul>
 </div>

 <div id="data">
    <-- load content xml here and style with xsl-->
 </div>

Open in new window


 ?xml version="1.0" ?> 
<document>
	<section id="6935f04648c3c3b47542a63ca4609cc7">
		<data>Start cover</data>
	</section>
	<section id="9f0c662896f9d254c1c265bc1b7af92d">
		<data>TOC</data>
	</section>
	<section id="f824d88cb5b7cef4cd861b2be72e04bb">
		<data>Argumentary</data>
		<chapter id="ebdddb985a739f84b58fcca1fb2ca378">
			<data>Chapter 1</data>
			<subchapter id="be91fade2e1cf544f93919b17d300e10">
				<data>Subchapter 1.1</data>
				<topic id="3b942fae1596a5e4a94c073ea040781e">
					<data>Topic A</data>
					<paragraph id="9ebae5de1075efb4699abaaf106acf57" level="1">Welldone</paragraph>
					<paragraph id="30ddac0f0c0de76479e64d16ed645873" level="2">not so good</paragraph>
					<paragraph id="1a53acd31aaa89d40172923ff2b20cb2" level="3">That look good.</paragraph>
					<paragraph id="a389dad1a9ddf9c4190cf6e2caf5bc25" level="1">yes it it.</paragraph>
				</topic>
				<topic id="9bafd300ad209e9489a4dd7acf0a6e06">
					<data>Topic B</data>
					<paragraph id="f65352c0e8ce90e4b990c3a0a8087968" level="1">Some text hello </paragraph>
					<paragraph id="e985b199564be424f52cf9d190bc42f2" level="1">some text.</paragraph>
				</topic>
			</subchapter>
</chapter>
</section>

Open in new window


I want when user cick on li that has id= 9ebae5de1075efb4699abaaf106acf57 then load content from xml put back ( fomart with xsl to <div id="data">)

Anyone could give me some code that I achieved this?
0
Comment
Question by:pelnisgproup
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 43

Expert Comment

by:Rob
ID: 39620463
How are you loading the xml? Ajax?
What is the server environment? Ie php, .net
I would suggest loading the xml into JavaScript when the page loads, parsing into an object/array, indexed by your UIDs.
I'll post some code showing you what I mean when I get back to my computer
0
 
LVL 43

Expert Comment

by:Rob
ID: 39620476
This was an example of leading and parsing xml that I did the other day http://jsbin.com/UkufIGi/2/edit
0
 
LVL 43

Accepted Solution

by:
Rob earned 2000 total points
ID: 39620795
Data with your example: http://jsbin.com/oFIbebi/4/edit

$(document).ready(function() {
  // in the following function you would use type: 'xml'
  // and url is the url of your xml on your server
  // the url must be on the same domain as your website
  $.ajax({
    method: 'get',
    url: 'OJoXiWe/2/',
    type: 'json',
    success: function(data) {
      // when type: 'xml' above, data will contain the xml in an object so the following is only relevant for this example / testing
      parser=new DOMParser();
      window.xmlDoc=parser.parseFromString(data.javascript,"text/xml");
      
      // xmlDoc will be the same as data when type: 'xml' and url are on your site
      
 console.log($(xmlDoc).find("paragraph[id=9ebae5de1075efb4699abaaf106acf57]").text());
    }
  });

$("li").on("click",function() {
// alert(this.id);
var msg=$(xmlDoc).find("paragraph[id="+this.id+"]");
alert(msg.text());
});
});

Open in new window

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question