Hi,
I've got the following piece of code that's causing me a bit of a problem
XmlDocument doc = new XmlDocument ();
XmlNode rootNode = doc.CreateNode (XmlNodeType.El ement, "usersettin gs",
null);
User user = new User (userid);
XmlNode rolesNode = user.GetRoles ();
rootNode.Append Child (rolesNode);
:
:
The last line (rootNode.Appen dChild (rolesNode)) throws an exception "The
node to be inserted is from a different document context." How can I work
around this? The code above is from a Web-service that collects various
information regarding a user from different sources each of which returns an
XmlNode. The web-service adds each XmlNode to a "root" node and then returns
this "root" node to the client.
Eirik M. 2 55620
The proble you're having relates to the fact that the user object is
creating a node from othe document, rather than from doc.
Either you pass doc to GetRoles so that the nodes are created from the
correct instance, or you may have to use ImportNode
rootNode.Append Child(doc.Impor tNode(rolesNode ,true));
instead of the previous AppendChild.
best regards
ricardo
"Eirik M." <eirik_at_stock point_dot_no> wrote in message
news:eC******** ******@tk2msftn gp13.phx.gbl... Hi,
I've got the following piece of code that's causing me a bit of a problem
XmlDocument doc = new XmlDocument (); XmlNode rootNode = doc.CreateNode (XmlNodeType.El ement, "usersettin gs", null); User user = new User (userid); XmlNode rolesNode = user.GetRoles (); rootNode.Append Child (rolesNode); : :
The last line (rootNode.Appen dChild (rolesNode)) throws an exception "The node to be inserted is from a different document context." How can I work around this? The code above is from a Web-service that collects various information regarding a user from different sources each of which returns
an XmlNode. The web-service adds each XmlNode to a "root" node and then
returns this "root" node to the client.
Eirik M.
Hi, Ricardo
Thanks for your quick reply.
"news.microsoft .com" <ricardo pereira> wrote in message
news:ur******** ******@TK2MSFTN GP11.phx.gbl... The proble you're having relates to the fact that the user object is creating a node from othe document, rather than from doc.
Either you pass doc to GetRoles
Nah, don't wan't to pass it around.
so that the nodes are created from the correct instance, or you may have to use ImportNode
rootNode.Append Child(doc.Impor tNode(rolesNode ,true));
Did the trick! instead of the previous AppendChild.
best regards ricardo
Eirik M ^_^ "Eirik M." <eirik_at_stock point_dot_no> wrote in message news:eC******** ******@tk2msftn gp13.phx.gbl... Hi,
I've got the following piece of code that's causing me a bit of a
problem XmlDocument doc = new XmlDocument (); XmlNode rootNode = doc.CreateNode (XmlNodeType.El ement, "usersettin gs", null); User user = new User (userid); XmlNode rolesNode = user.GetRoles (); rootNode.Append Child (rolesNode); : :
The last line (rootNode.Appen dChild (rolesNode)) throws an exception
"The node to be inserted is from a different document context." How can I
work around this? The code above is from a Web-service that collects various information regarding a user from different sources each of which
returns an XmlNode. The web-service adds each XmlNode to a "root" node and then returns this "root" node to the client.
Eirik M.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Kali K E |
last post by:
Hi,
I could not understand how I can do the following things in Python.
Please help me.
1. First I have to find the current directory from where the script is
invoked.
2. Next I have to form a directory structure there. If the current
directory in step 1 is /home/mylogin, then from there I have to build
a directory structure like
/home/mylogin/result
|
by: Pavils Jurjans |
last post by:
Hello,
I am interested in getting the XML contents as text between two XML elements
that I know follow each other. They could be in completely different levels,
but in XML file the first is above the second. Of course, a code could be
written that would first read InnerXml property of the start tag, extract
the opening parens <starttag>, then read all text nodes within, then do the
same with child nodes, then with start tag next...
|
by: Horst Walter |
last post by:
What is wrong here?
IPAddress ipAddress = IPAddress.Parse("10.10.20.1");
IPEndPoint ipEndPoint = new IPEndPoint(ipAddress, this.port);
this.tcpClient = new TcpClient(ipEndPoint); // PROBLEM HERE
=> Exception: "The requested address is not valid in its context"
This works:
|
by: Paw Pedersen |
last post by:
When you are "working" on a specific node from a XmlDocument instance, is it
possible to get the full xpath to this node?
Regards Paw
|
by: |
last post by:
Is there any sample about getting the results from executing an exe using
C#?
Thanks for answering.
| |
by: Paul H |
last post by:
I am trying to get the spec for a database. The trouble is the client
frequently blurts out industry jargon, speaks insanely quickly and is easily
sidetracked. They are currently using around 30 different spreadsheets and
they want me to refine those spreadsheets in to an Access DB. The current
system is a complete mess.
My gut feeling is the project is actually fairly straightforward, but after
several meetings, emails and telephone...
|
by: scripter199 |
last post by:
Hi,
Im adding textboxes dynamically from an onclick event that calls the function below:
function addRowDynamic()
{
rowCnt++;
lookupCnt++;
id++;
//add a row to the rows collection and get a reference to the new added row
var newRow = document.all("D").insertRow(rowCnt);
|
by: tamasumalta |
last post by:
I am using the attached code
Private Sub StartApplicationProcess
InitialiseObject()
oWord.Visible = True
oDoc = oWord.Documents.Open(StrStackPath)
oWord.Visible = True
end sub
The variables oWord and oDoc are declared in the class as below
|
by: yogarajan |
last post by:
The specified module could not be found. (Exception from HRESULT: 0x8007007E)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.FileNotFoundException: The specified module could not be found. (Exception from HRESULT: 0x8007007E)
Source Error:
An unhandled...
|
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,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
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...
|
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();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
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...
| |