473,799 Members | 3,061 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XMLNode

In VB.Net, the following declaration builds and executes with no exceptions:

Dim XMLDoc As New XmlDocument
Dim Node As XmlNode

But in C#, the following (equivalent?!) returns the build error "XMLNode
does not exist in the current context.":

XmlDocument XMLDoc = new XmlDocument();
XmlNode Node = XMLNode;
Aug 2 '06 #1
3 2883
Earl wrote:
In VB.Net, the following declaration builds and executes with no exceptions:

Dim XMLDoc As New XmlDocument
Dim Node As XmlNode

But in C#, the following (equivalent?!) returns the build error "XMLNode
does not exist in the current context.":

XmlDocument XMLDoc = new XmlDocument();
XmlNode Node = XMLNode;
Just do:

XmlDocument XMLDoc = new XmlDocument();
XmlNode Node;

You're just declaring the variable, without initializing it at all.

Jon

Aug 2 '06 #2
Earl wrote:
In VB.Net, the following declaration builds and executes with no exceptions:

Dim XMLDoc As New XmlDocument
Dim Node As XmlNode

But in C#, the following (equivalent?!) returns the build error "XMLNode
does not exist in the current context.":

XmlDocument XMLDoc = new XmlDocument();
XmlNode Node = XMLNode;
Your translation is awry. You have the first line right: the translation of

Dim variable_name As New type_for_variab le

(a declaration and and assignment in one) is indeed

type_for_variab le variable_name = new type_for_variab le();

, and is in fact one of the rare cases where VB uses fewer characters
than C#. But where VB does a simple declaration:

Dim variable_name As type_for_variab le

without actually assigning any value to variable_name, the C# maintains
its usual terseness-advantage:

type_for_variab le variable_name;
--
Larry Lard
la*******@googl email.com
The address is real, but unread - please reply to the group
For VB and C# questions - tell us which version
Aug 3 '06 #3
Thanks to both you and Jon.

"Larry Lard" <la*******@goog lemail.comwrote in message
news:4j******** ****@individual .net...
Earl wrote:
>In VB.Net, the following declaration builds and executes with no
exceptions:

Dim XMLDoc As New XmlDocument
Dim Node As XmlNode

But in C#, the following (equivalent?!) returns the build error "XMLNode
does not exist in the current context.":

XmlDocument XMLDoc = new XmlDocument();
XmlNode Node = XMLNode;

Your translation is awry. You have the first line right: the translation
of

Dim variable_name As New type_for_variab le

(a declaration and and assignment in one) is indeed

type_for_variab le variable_name = new type_for_variab le();

, and is in fact one of the rare cases where VB uses fewer characters than
C#. But where VB does a simple declaration:

Dim variable_name As type_for_variab le

without actually assigning any value to variable_name, the C# maintains
its usual terseness-advantage:

type_for_variab le variable_name;
--
Larry Lard
la*******@googl email.com
The address is real, but unread - please reply to the group
For VB and C# questions - tell us which version

Aug 4 '06 #4

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

Similar topics

9
8133
by: JJ | last post by:
Hi All, I noticed that XmlNode and XpathNavigator are quite similiar. XmlNode seems to navigate over an XML Doc and so does XPathNav so when do I use XPathNavigator instead of XmlNode? Thanks, JJ
3
8120
by: Mahesh Devjibhai Dhola | last post by:
Hi All, I want to make a custom class in c#, which extends System.Xml.XmlNode class of BCL. Now in custom class, I have implement abstract methods of XmlNode class also. Now when I am trying to run the class it gives an error that "System.Xml.XmlNode.XmlNode() is inaccessible due to its protection level". This error comes because XmlNode has not any public constructor. I found XmlNode has two constructor but both are private or friend...
5
5101
by: Paul | last post by:
Here I have the definition of an XmlNode which is a property (PayPreference) on my Customer class containing an enum describing how the customer will pay. <PayPerference xsi:type="a4:Customer+CustomerPayOptions" xmlns:a4="http://schemas.microsoft.com/clr/nsassem/OsfDomain.Resources.Stage/OsfDomain%2C%20Version%3D1.0.0.1%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3Dnull">cash</PayPerference> I now want to add this XmlNode to a different...
1
4744
by: andrej | last post by:
hi, ich habe eine anwendung, welche ein xml document erstellt. um festzustellen, ob ein element bereits vorhanden ist, verwende ich die funktion selectsinglenode( ....) diese funktion liefert mir ein element des typs node.
5
2144
by: Mahesh Devjibhai Dhola | last post by:
Hi All, I want to make a custom class in c#, which extends System.Xml.XmlNode class of BCL. Now in custom class, I have implement abstract methods of XmlNode class also. Now when I am trying to run the class it gives an error that "System.Xml.XmlNode.XmlNode() is inaccessible due to its protection level". This error comes because XmlNode has not any public constructor. I found XmlNode has two constructor but both are private or friend...
3
5060
by: Mae | last post by:
Dear All, I have a problem here, I'm using C# Webform calling a webservices. The webservices return me a XMLnode, using this XMLnode I want to convert it to dataset so I can bind to the datagrid, by extracting the <CustomerData></CustomerData> block from the xmlnode. Below is the sample of xmlnode return from webservices. <?xml version="1.0" encoding="utf-8"?>
1
313
by: PaulF | last post by:
I am writing a web service that accepts and returns an XML message - I know the issues behind this but want to be able to process the messages generically using XSD / XSLT. My problem occurs with the way the .NET framework appears to handle the XmlNode, in particular the generation of the WSDL. The details follow: I define the code behind method as
5
2717
by: =?Utf-8?B?VGhlIE1hbiBGcm9tIFNRTA==?= | last post by:
I'm having the darndest XML config file problem that I really need help with. I'm supporting a .NET 1.1 desktop application with its own config file, and I implement IConfigurationSectionHandler so I can have a custom config section in my config file. The IConfigurationSectionHandler.Create method just returns the 'section' XmlNode back to the consumer. The config file looks kind of like this: <?xml version="1.0" encoding="utf-8" ?>...
2
4629
by: =?iso-8859-1?Q?Norbert_P=FCrringer?= | last post by:
Hello! Is it possible to use the object XMLNode as a parameter in an interface function of a WCF service? In my case I get the error message: XmlNode ProcessServiceRequest(XmlNode request); Unable to serialize type "System.Xml.XmlNode". Use the attribute
0
9686
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9540
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10222
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9068
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7564
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6805
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3757
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.