Solved

XML IMAGE IN A TEXT NODE

Posted on 2008-06-20
11
288 Views
Last Modified: 2013-12-25
HI GUYS,

I am developing a flash quiz using XML. I am stuck because i need to insert a small image into the question line between text for a question. Is there a way to do this in the node used for the question.
I have another node for a question image but it is not in the line it is seperate. i need this image to display in the line.

any ideas??

please see xml code - i have marked in the question node where i need the image to go..



XML Code
<item><!-- Q3 -->
<sectiontitle>GCSE (Ordinary) Course Section 1: Transformations</sectiontitle>
<question>The triangle ABC with vertices A(1, - 2),  B(3, - 6) and C(- 4, - 5) is enlarged, using scale factor - image to go here-->><img src="Question3/Q3.jpg"/> and centre the origin (0, 0).<question> 
<feedback>For question three, this is the feedback</feedback>
<image></image>
<Qtype>Image</Qtype>
<answer>Question3/A1.jpg</answer>
<answer>Question3/A2.jpg</answer>   
<answer correct="y">Question3/A3.jpg</answer>
<answer>Question3/A4.jpg</answer>     
</item>

Open in new window

0
Comment
Question by:kingkev83
[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
  • 6
  • 5
11 Comments
 
LVL 10

Expert Comment

by:bluefezteam
ID: 21830535
Are you saying that you want an image as part of your questions text?
So in the paragraph of text that is the question, there's an image?

If so you can set the textfield that holds the question as a HTML textfield and use the <img src="image.jpg"/> in your question. SO your question would be one long string with the img tag used.
0
 

Author Comment

by:kingkev83
ID: 21831434
I've tried that as you can see from my xml statement, but it only displays in the dynamic textbox if i hardcode it into flash ie.
actionscript:
 my_text.htmlText = currentQuizItem.getQuestion() + " <img src='Question3/Q3.jpg'/>";

i need it to actually read from XML but it just shows a blank and any text after it is missing when it runs

XML code:
  <question>The triangle ABC with vertices A(1, - 2),  B(3, - 6) and C(- 4, - 5) is enlarged, using scale factor -<img src="Question3/Q3.jpg"/> and centre the origin (0, 0). </question>

in flash the question shows until "factor - " then its blank

0
 
LVL 10

Expert Comment

by:bluefezteam
ID: 21831637
hmm maybe the "" around the image tag are confusing flash when loading through xml? It's reading it in as a variable rather than a string.

Have you tried single quote ''

also needs to be exported as flash 7 or above if that helps for IMG to work ina  text field
0
Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

 
LVL 10

Expert Comment

by:bluefezteam
ID: 21831652
perhaps URL encode? %22 = "
0
 

Author Comment

by:kingkev83
ID: 21831959
It doesn't like the < ive tried CDATA and using &lt = < but it does not want to show anything past it. it will show " though
0
 

Author Comment

by:kingkev83
ID: 21832176
OK i got it working by using <lt as "<" and &gt as ">" , it returns the line before the image but at lease it shows up where i want it as the following text is displayed after the image.

Next thing is that as you said to show these images i have to use Flash 7 or above, i just realised i was using flash 6 before and now the answer images wont come over in the array in flash.. the code works great in vers 6 but in 7 the code must be different. the Question, Sectiontitle, feedback comes over ok but the Qtype and Images fail

 can you help..

Actionscript:
function onQuizData(success) {
	var quizNode = this.firstChild;
	var quizTitleNode = quizNode.childNodes[0];
	title = quizTitleNode.firstChild.nodeValue;
	var i = 0;
	// <items> follows <title>
	var itemsNode = quizNode.childNodes[1];
	while (itemsNode.childNodes[i]) {
		var itemNode = itemsNode.childNodes[i];
		// <item> consists of  <question> and one or more <answer>
		// <question> always comes before <answer>s (node 0 of <item>)
		var SectionTitleNode = itemNode.childNodes[0];
		var questionNode = itemNode.childNodes[1];
		// <feedback>
		var feedbackNode = itemNode.childNodes[2];
		//<Image>
		var imageNode = itemNode.childNodes[3];
		//QuestionType
		var QtypeNode = itemNode.childNodes[4];
		
		quizItems[i] = new QuizItem(SectionTitleNode.firstChild.nodeValue, questionNode.firstChild.nodeValue, feedbackNode.firstChild.nodeValue, imageNode.firstChild.nodeValue, QTypeNode.firstChild.nodeValue);
		var a = 5;
		;
		// <answer> follows <question>
		var answerNode = itemNode.childNodes[a++];
		while (answerNode) {
			var isCorrectAnswer = false;
			if (answerNode.attributes.correct == "y") {
				isCorrectAnswer = true;
			}
			quizItems[i].addAnswer(answerNode.firstChild.nodeValue,isCorrectAnswer);
			// goto the next <answer>
			answerNode = itemNode.childNodes[a++];
		trace(answerNode[i]);
		}
		i++;
 
XML:
<item><!-- Q3 -->
<sectiontitle>GCSE (Ordinary) Course Section 1: Transformations</sectiontitle>
        <question>The triangle ABC with vertices A(1, - 2),  B(3, - 6) and C(- 4, - 5) is enlarged, using scale factor &lt;img src="Question3/Q3.jpg" align="absmiddle"/&gt; 
  and centre the origin (0, 0). </question>
        <feedback>For question three, this is the feedback</feedback>
        <image></image>
        <Qtype>Image</Qtype>
        <answer>Question3/A1.jpg</answer>
        <answer>Question3/A2.jpg</answer>   
        <answer correct="y">Question3/A3.jpg</answer>
        <answer>Question3/A4.jpg</answer>     
        </item>

Open in new window

0
 
LVL 10

Expert Comment

by:bluefezteam
ID: 21835314
can you post the fla file - you may have to rename the extension to .jpg to allow it to be loaded into this system.

I'll have a look at it over the weekend, and hopefully be able to assist a bit.
0
 

Author Comment

by:kingkev83
ID: 21844473
hi bluefezteam, please see attached my fla file and xml file, This code works with flash 6 settings but when i use flash 7 the images for the answers don't appear except for the image in the Question textbox, i have renamed the files so they can be uploded.
GCSEOrdFreeTestXML.zip
0
 
LVL 10

Expert Comment

by:bluefezteam
ID: 21846733
ok just downloaded it - will see what I can do.
0
 

Author Comment

by:kingkev83
ID: 21908447
did you get anywhere with that
0
 

Accepted Solution

by:
kingkev83 earned 0 total points
ID: 21925400
Didnt bother with text fields in the end, too much hard work, i just used images to display the questions and text that way i can control the layout and styles easier, if i need to edit a question i can then simply recreate the image.  
0

Featured Post

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Node.js 11 82
Unexpected End of File 11 87
need help with share buttons 11 106
type of website 13 53
Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
CTAs encourage people to do something specific to show interest in your company, product or service. Keep reading to learn why CTAs should always be thought of as extremely important, albeit small, sections of websites.
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

751 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