473,414 Members | 1,878 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,414 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 1008
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

25
by: Brian Patterson | last post by:
I have noticed in the book of words that hasattr works by calling getattr and raising an exception if no such attribute exists. If I need the value in any case, am I better off using getattr...
20
by: qscomputing | last post by:
Hi, I've developed in several other languages and have recently found Python and I'm trying to use it in the shape of the PythonCard application development tool. My two questions: 1. What...
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: iTISTIC | last post by:
Developing a new app and am trying to make this my first truly OOP/3-Tier app. I understand the principles of the presentation, business, and data layers. I do, however, have some questions on...
6
by: Tex | last post by:
I am writting a survey system web application. I am using ASP.Net 2, C# and MS SQL 2005. I am able to store surveys and questions associated to the surveys just fine. The problem I am having is...
1
by: hmmmmmm | last post by:
heya, this is actually the first time i visit this forum, but i really wanted to make something.. but i kinda ran out of idea's <_< with html you can 'fill in' forms by just hitting an extern...
9
by: Setash | last post by:
I've got a tiny bit of coding background, but its not the most extensive. That said, I'm trying to wrap my head around python and have a couple questions with classes and functions. Two...
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...
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:
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.