473,395 Members | 2,192 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,395 software developers and data experts.

2 tiny questions

Simple questions that have just been kickin my butt!

Question 1:
Here's the code:

XmlNode node1;
XmlAttribute attribute1;
node1 = this.xmlDoc.DocumentElement[sectionName];
attribute1 = node1.Attributes.GetNamedItem(attributeName);

And here's the error:

Cannot implicitly convert type 'string' to 'System.Xml.XmlAttribute'
Question 2:
How do you add those nice comments to a class that get pulled up in
Intellisense?

Thank you,
Sueffel
Nov 16 '05 #1
7 1356
Just for some depth, here's the entire function:

public string GetConfigAttribute(string sectionName, string attributeName,
bool createIfNotFound)
{
XmlNode node1;
XmlAttribute attribute1;
node1 = this.xmlDoc.DocumentElement[sectionName];
attribute1 = node1.Attributes.GetNamedItem(attributeName);
if ((attribute1 == null) && createIfNotFound)
{
attribute1 = this.xmlDoc.CreateAttribute(attributeName);
node1.Attributes.Append(attribute1);
this.xmlDoc.Save(this.configFileName);
}
if (attribute1 != null)
{
return attribute1.Value;
}
return "";
}

Thanks again,
Sueffel
Nov 16 '05 #2
"Sueffel" <so*****@somewhere.com> wrote in news:eWtlPx0HEHA.3748
@tk2msftngp13.phx.gbl:
Question 1:
Here's the code:

XmlNode node1;
XmlAttribute attribute1;
node1 = this.xmlDoc.DocumentElement[sectionName];
attribute1 = node1.Attributes.GetNamedItem(attributeName);

And here's the error:

Cannot implicitly convert type 'string' to 'System.Xml.XmlAttribute'
Assuming that the variables like 'sectionName' and so forth are defined
correctly, I get a different error - cannot convert XmlNode to
XmlAttribute. This is expected and you can simply cast the XmlAttribute to
an XmlNode, or define attribute1 as an XmlNode to start with.
Question 2:
How do you add those nice comments to a class that get pulled up in
Intellisense?


Comment the class and functions with /// comments - it will automatically
provide popups.

-mdb
Nov 16 '05 #3
I ended up finding my original source for this sucker, and feel kinda
stupid. Here's the function as it should look:

public string GetConfigAttribute(string sectionName, string attributeName,
bool createIfNotFound)
{
XmlNode sectionNode = this.xmlDoc.DocumentElement[sectionName];
XmlAttribute attr = sectionNode.Attributes[attributeName];
if (attr == null)
{
if (createIfNotFound)
{
attr = this.xmlDoc.CreateAttribute(attributeName);
sectionNode.Attributes.Append(attr);
this.xmlDoc.Save(this.configFileName);
}
}
return (attr == null) ? "" : attr.Value;
}

As for the second question, here's what I have:

/// <summary>
/// Gets the specified Attribute
/// </summary>
/// <param name="sectionName">Name of section</param>
/// <param name="attributeName">name of attribute</param>
/// <param name="createIfNotFound">Create section if it doesn't
exist</param>
/// <returns></returns>

The XML document did make, but I still don't have that info in the
Intellisense window. That's the only reason I'm doing this in C#, otherwise
I'd do it in my native VB.NET.

Otherwise, I just need to figure out why I'm havingmy other error, and I can
re-release this sucker. Funny how finickey things can be.

Thanks again,
Suefffel
Nov 16 '05 #4
Lemme try to be claer, after reading my posts, I think I'm not speaking of
the correct things. basically, when you type String s = New String(
When you type the ( the little box pops up and gives a description of the
peramiters. That's what I'm after.

Thanks again,
Sueffel
Nov 16 '05 #5
Sueffel <so*****@somewhere.com> wrote:
The XML document did make, but I still don't have that info in the
Intellisense window. That's the only reason I'm doing this in C#, otherwise
I'd do it in my native VB.NET.


To use XML documentation within other solutions, you need to have the
..xml file in the same location as the assembly, and it must have
*exactly* the same name as the assembly itself, but with .xml instead
of .dll at the end. Within the same solution, I *think* it should come
up anyway, even if you don't build the .xml file.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #6
Sueffel,
Make sure you have specified the XML Documentation File parameter in the
project Configuration Build properties with the correct xml file name. This
will build the documentation file to be used in other projects. This needs
to be specified for both release and debug builds.

Ron Allen
"Sueffel" <so*****@somewhere.com> wrote in message
news:uN**************@TK2MSFTNGP12.phx.gbl...
I ended up finding my original source for this sucker, and feel kinda
stupid. Here's the function as it should look:

public string GetConfigAttribute(string sectionName, string attributeName,
bool createIfNotFound)
{
XmlNode sectionNode = this.xmlDoc.DocumentElement[sectionName];
XmlAttribute attr = sectionNode.Attributes[attributeName];
if (attr == null)
{
if (createIfNotFound)
{
attr = this.xmlDoc.CreateAttribute(attributeName);
sectionNode.Attributes.Append(attr);
this.xmlDoc.Save(this.configFileName);
}
}
return (attr == null) ? "" : attr.Value;
}

As for the second question, here's what I have:

/// <summary>
/// Gets the specified Attribute
/// </summary>
/// <param name="sectionName">Name of section</param>
/// <param name="attributeName">name of attribute</param>
/// <param name="createIfNotFound">Create section if it doesn't
exist</param>
/// <returns></returns>

The XML document did make, but I still don't have that info in the
Intellisense window. That's the only reason I'm doing this in C#, otherwise I'd do it in my native VB.NET.

Otherwise, I just need to figure out why I'm havingmy other error, and I can re-release this sucker. Funny how finickey things can be.

Thanks again,
Suefffel

Nov 16 '05 #7
I didn't have the name exactly as the assembly name. That problem is fixed.
Once again, thank you all for all your help, it is greatly appreciated.

Sueffel
"Sueffel" <so*****@somewhere.com> wrote in message
news:uN**************@TK2MSFTNGP12.phx.gbl...
I ended up finding my original source for this sucker, and feel kinda
stupid. Here's the function as it should look:

public string GetConfigAttribute(string sectionName, string attributeName,
bool createIfNotFound)
{
XmlNode sectionNode = this.xmlDoc.DocumentElement[sectionName];
XmlAttribute attr = sectionNode.Attributes[attributeName];
if (attr == null)
{
if (createIfNotFound)
{
attr = this.xmlDoc.CreateAttribute(attributeName);
sectionNode.Attributes.Append(attr);
this.xmlDoc.Save(this.configFileName);
}
}
return (attr == null) ? "" : attr.Value;
}

As for the second question, here's what I have:

/// <summary>
/// Gets the specified Attribute
/// </summary>
/// <param name="sectionName">Name of section</param>
/// <param name="attributeName">name of attribute</param>
/// <param name="createIfNotFound">Create section if it doesn't
exist</param>
/// <returns></returns>

The XML document did make, but I still don't have that info in the
Intellisense window. That's the only reason I'm doing this in C#, otherwise I'd do it in my native VB.NET.

Otherwise, I just need to figure out why I'm havingmy other error, and I can re-release this sucker. Funny how finickey things can be.

Thanks again,
Suefffel

Nov 16 '05 #8

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

Similar topics

2
by: Sven Kobow | last post by:
Hello, I'm not yet a python programmer but a python user. I faced a problem with tiny fonts in a wxPython app on a GNU/Debian system. Under Gentoo Linux the fonts are displayed in a normal...
0
by: Justin Ezequiel | last post by:
Can somebody please give me a URL to where I can download the DTD? I've Googled and browsed all through http://openreport.org/ with no success.. I've subscribed to the OpenReport mailing list but...
5
by: Mel | last post by:
i would like to place a tiny image on the top-left corner of all screens and on clicking the image to to http://www.somewhere.com url can you please help ?
7
by: Werner Nussbaumer | last post by:
Hello I am searching for a version of the Tiny C compiler for Windows 32. I downloaded a version from http://fabrice.bellard.free.fr/tcc/ but the make command displayed error messages: ...
7
by: Sueffel | last post by:
Simple questions that have just been kickin my butt! Question 1: Here's the code: XmlNode node1; XmlAttribute attribute1; node1 = this.xmlDoc.DocumentElement; attribute1 =...
5
by: soeren | last post by:
Hello, two days ago I stumbled across a very strange problem that came up when we were printing tiny double numbers as strings and trying to read them on another place. This is part of an object...
2
by: Martijn Mulder | last post by:
I want to implement a tiny window in my application, one that you typically invoke via the menu-option Window -Toolbar. It must be floating, not restricted to the client area of the controlling...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
14
by: rtk | last post by:
I'm looking for information on building a tiny/small/minimalist/ vanilla python interpreter. One that implements the core language and a few of the key modules but isn't tied to any specific...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...

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.