473,399 Members | 3,656 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,399 software developers and data experts.

How can I pass an XmlDocument as a value type?

I would like to pass an XmlDocument to a method as a non-referenced object.
Can this be done?
Jun 22 '06 #1
4 1967
William wrote:
I would like to pass an XmlDocument to a method as a non-referenced
object. Can this be done?


Hi William,

You'll need to clone it. I believe the XmlDocument object exposes a Clone
method, which you can use to clone it, and so pass it in like this:

SomeClass.SomeMethod( theXmlDoc.Clone() as XmlDocument );

The reason for the 'as' there is that the Clone() method returns an XmlNode,
and (hopefully) will actually return the cloned instance of the
XmlDocument, since XmlDocument inherits from XmlNode.

Hope this helps,
-- Tom Spink
Jun 22 '06 #2
I'm not sure what you mean by this. All object variables in C# are
references, so the idea of passing a non-referenced object doesn't make
sense. What are you trying to do?

--
Jeffrey Hornby
Hornby Consulting, Inc.

"William" wrote:
I would like to pass an XmlDocument to a method as a non-referenced object.
Can this be done?

Jun 22 '06 #3
Hi,

Would mind to further explain what you want?

If you want to modify it inside a method and this action do not have effect
in the calling method then you need to clone it.
You can save to a string and then create a new document from this string.
Not sure if there is a better way .
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"William" <nf*@nospam.com> wrote in message
news:eQ**************@TK2MSFTNGP05.phx.gbl...
I would like to pass an XmlDocument to a method as a non-referenced object.
Can this be done?

Jun 22 '06 #4
I was wonering if there might be something comparable to boxing/unboxing for
reference types, but this does not seem to be the case. I decided to go
ahead and just clone it.

"Jeffrey Hornby" <Je***********@discussions.microsoft.com> wrote in message
news:5E**********************************@microsof t.com...
I'm not sure what you mean by this. All object variables in C# are
references, so the idea of passing a non-referenced object doesn't make
sense. What are you trying to do?

--
Jeffrey Hornby
Hornby Consulting, Inc.

"William" wrote:
I would like to pass an XmlDocument to a method as a non-referenced
object.
Can this be done?

Jun 22 '06 #5

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

Similar topics

3
by: serge calderara | last post by:
Dear all, I have define a configuration file for my application with different section groups and settings belonging to each individual group like as follow : ...
2
by: John Bailo | last post by:
I developed a web method that returns type XmlDocument. But a client calling the web method will only accept the return value as datatype XmlNode. Why? -- http://antimeme.texeme.com
8
by: Whugster | last post by:
I have this really frustrating problem when calling XmlDocument.Load(string filename). Whenever I call this method in a web application in my Windows XP development PC, I get the following error: ...
2
by: Shailendra Batham | last post by:
hi gurus I have a asp.net web services and in that i have a function which returns XmlDocument as the return value, when I test the service it works fine and I can see the XML. When I try to...
4
by: David Thielen | last post by:
Hi; I have nodes in the XmlDocument I create that need to be written exactly as is - not converting < to %lt; and no changing the whitespace. (This is for the SpreadsheetML schema and it reads...
4
by: aaa | last post by:
Can someone show me a snippet that creates a very simple XML doc with either a root and chilc nodes or root child nodes, and attributes. I have looked all around and every example I try I get an...
2
by: SwatSoftwareDev | last post by:
Hi All, I want to use XML technologies with SQL Server 2000 for sending master details data from Application to SQL Server. I'm using xmldocument class for writing data in the form of attribute...
0
by: delphiconsultingguy | last post by:
Hi all, Spent WAAAYYY too much time trying to figure this out because there's not many good examples out there, so in the interest of sparing y'all from suff'rin same, I've pasted it into...
2
by: ojinfo | last post by:
hi i am currently working on a web service which is supposed to take a xmldocument as input parameter, and then returns another xmldocument. the service is added to the web references in my...
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: 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
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...
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
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
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...
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
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.