473,396 Members | 1,998 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to parse XML in C# (tooltips)

Nat
Hi

<..I'm useing c# asp.net, and it's webapplications..>

I have a content.xml file with some content id's, and a text

(fx.: <content Id = bla bla bla bla></content id>

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>+");
}

I've also heard that I could parse the .xml, what does that mean, and
how is that done?

Thanks, Nat
Nov 15 '05 #1
4 15364
XML parsing is done using the classes as defined in the System.Xml namespace
to break up the xml content into more manageable bits that you can consume
more easily.

Since you have an xml file, take a look at the System.Xml.XmlDocument class.
It's not the most efficient (it sticks the whole XML file in memory and
processes it there), but it's by far the easiest to use.

Ben
"Nat" <nm@sondagsavisen.dk> wrote in message
news:da**************************@posting.google.c om...
Hi

<..I'm useing c# asp.net, and it's webapplications..>

I have a content.xml file with some content id's, and a text

(fx.: <content Id = bla bla bla bla></content id>

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>+");
}

I've also heard that I could parse the .xml, what does that mean, and
how is that done?

Thanks, Nat

Nov 15 '05 #2
> 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
Nov 15 '05 #3
Nat
Thanks for all the help

I've tried putting in the following code:

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();
document.write(\"" +helpString+ "\")'></span>");
}

The "tooltip" shows, but when I click the image the window doesn't
open.... I can't figure out why, because if I view the html source it
seems like it should work.

What am I missing to get the new window to open on click???

Thanks

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #4
Nat

Okay, I solved it my self by adding a 'a href', see code below:

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' a href='#' onclick = 'myWin =
window.open(); myWin.document.write(\"" +helpString+
"\")'></a></span>");
}

Bur now I want to add some parameters in to the win.open(), så I can
control the window size, color and name - how do I write that into the
code above??

Thanks
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: shraddha | last post by:
Hi I want to implement dynamic interactive tooltips in java so that the user can expand / collapse them. Also, if there are hyperlinks in the tooltip text, the user should be able to follow up...
1
by: David Ei | last post by:
I'm working on a C# Windows Forms application that is leaking memory. I've been using the SciTech NetMem Profiler 2 (A really great tool, BTW) to track down leaks. I've found one related to...
3
by: Wayne | last post by:
Is anybody aware of other software conflicting with Access and disabling the tool tips. I've had this problem in the past and now have it again after rebuilding my desktop and notebook. Both fail...
1
by: Wayne Aprato | last post by:
Tooltips in Access have not worked on my machine for a long time despite several reinstalls of the operating system and applications at fairly regular intervals. I have finally pinned down the...
4
by: Cesario | last post by:
I'm trying to display formatted multi-line text in tooltips. It seems that the newline character works fine whereas the 'tab' character is causing problems and can't display properly. More...
4
by: Jeff Beem | last post by:
I have a class that inherits from TreeView. The treeview has tooltips for the nodes but they're showing up behind the form. Has anyone seen this? Are there any known fixes? Thanks in advance,...
21
by: PlainDave | last post by:
Hi, Is there a way to make windows tooltips stay up longer than the default 5 seconds using CSS in a web page? I'd prefer to have it stay visible as long as the mouse is over the "whatever." The...
1
by: Robert Smith | last post by:
Hello, I have a Tree that contains tooltips, however when I right click on a node of the tree the context menu covers up the tooltips and it looks rather unprofessional. I wish to hide the...
1
by: TyBreaker | last post by:
I have a simple form with a toolstrip on it and some toolstrip buttons. Tooltips work fine. But then I use the ShAppBarMessage API call to register the form as an Application Desktop Toolbar. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.