> The text in content.xml is used in some tooltips. My problem is now
that in some of tooltips the text from the conten.xml is to large, so
you can't get around to read it before it's gone. So I tried to put
the java window.open() into the write statement - but how do I get the
content id's text to show in the new window?
Some of the code that displays the tooltip looks like this:
protected override void Render(HtmlTextWriter w)
{
if (helpString!=null)
{
w.Write("<span class='tooltipIconOuter'><img
title='"+this.helpString+"' class='tooltipIconInner' align='center'
src='../Lib/images/questionmark.gif'#
onclick='window.open();'></span>+");
}
You need to get the reference to the new window and then write to its
document property. Try using this code instead:
protected override void Render(HtmlTextWriter w)
{
if (helpString!=null)
{
w.Write("<span class='tooltipIconOuter'><img
title = '"+this.helpString+"' class='tooltipIconInner' align='center'
src = '../Lib/images/questionmark.gif'#
onclick = 'myWin = window.open(); myWin.document.write(\"" + helpString
+ "\")'></span>+");
}
I've also heard that I could parse the .xml, what does that mean, and
how is that done?
Parsing an XML file is a process of converting a plain text representation
of the XML file into a logical representation, such as XML DOM. Parsing is
done in the background by various classes in System.Xml namespace, so you
don't need to worry about parsing itself. What you probably need is how to
extract specific information from the XML, where XPath is the easiest way
you can go. Try this:
// MyXMLFile.xml
<?xml version="1.0" encoding="utf-8" ?>
<root>
<content id="tooltip1">My tooltip</content>
<content id="tooltip2">Another tooltip</content>
<content id="tooltip3">Yet another tooltip</content>
</root>
// somewhere in a .cs class file
XmlDocument doc = new XmlDocument();
doc.Load("XMLFile1.xml");
string tooltip = "";
XmlNode tooltipNode = doc.SelectSingleNode("/root/content[@id='tooltip2']");
if (tooltipNode != null)
{
tooltip = tooltipNode.Value;
}
Hope this helps.
Regards,
--
Vjekoslav Babic, MCSA, MCDBA