/    Sign up×
Community /Pin to ProfileBookmark

Getting XML Text with Javascript

Hi, i have searched the forums for some help with this issue but did not appear to find anything – i apologise if there is already a thread for this!

I am trying to create some tool tips, basing the tool tip on data in an xml file. I am using javascript to obtain the data from the file.

i have an xml file:

[CODE]<Help updated=”Mon 12th March 2007″>
<HelpTopic name=”first”>
<ToolTip>first tool tip</ToolTip>
<HelpText>first help text</HelpText>
</HelpTopic>
</Help>[/CODE]

& the following Javascript:

[CODE]<script type=”text/javascript”>

var xmlDoc=new ActiveXObject(“Microsoft.XMLDOM”)
xmlDoc.async=”false”
xmlDoc.load(“help.xml”)
xmlObj=xmlDoc.documentElement.childNodes;
ToolTip.innerText = xmlObj.childNodes(0).item(0).text

</script>[/CODE]

I am trying to obtain “ToolTip” to use within a <span> I am doing this like:
<span title=”ToolTip”>Tool Tip Three</span>
Can some one please advise?

Cheers

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@KorMar 13.2007 — First, I guess you should use a crossbrowser parser for dealing with an XML file. See:

http://www.w3schools.com/dom/dom_parser.asp

Second innerText is an IE only method. Probably you should use innerHTML.

Now. You need also an event to show that tooltip (onmouseover? onclick?). And a function which will nest the code, and that function could be triggered by that event... can you detail a little bit your aim?
Copy linkTweet thisAlerts:
@toish100authorMar 13.2007 — i am simply trying to display some tool tips for various components on a web page.

I have already implemented a help page function using xml files & xsl, so i thought it might be nice to use this xml file also for displaying the tool tip text - as opposed to hard coding the text into the HTML.
×

Success!

Help @toish100 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...