473,804 Members | 2,296 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why so Finnicky about Node Copy?

Can someone show me how to append an XMLElement from one XMLDocument
as a child to an element in another XMLDocument? ( In one line of code
please )

I used to be able to say :

MyNode.AppendCh ild(OtherDoc.Do cumentElement)

No more in Dot Net.

TIA -
Brian
Nov 20 '05 #1
5 1353
On 4 Nov 2003 12:43:12 -0800, Brian wrote:
I used to be able to say :

MyNode.AppendCh ild(OtherDoc.Do cumentElement)


I think you need to use code similar to this (untested):

MyNode.AppendCh ild(New XmlNode(OtherDo c.DocumentEleme nt))

See if that works

--
Chris

To send me an E-mail, remove the underscores and lunchmeat from my E-Mail
address.
Nov 20 '05 #2
* bo***@vafb.com (Brian) scripsit:
Can someone show me how to append an XMLElement from one XMLDocument
as a child to an element in another XMLDocument? ( In one line of code
please )

I used to be able to say :

MyNode.AppendCh ild(OtherDoc.Do cumentElement)

No more in Dot Net.


Error message? You may want to clone the element by calling its 'Clone'
method before adding it to an other node.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

<http://www.plig.net/nnq/nquote.html>
Nov 20 '05 #3
Take a look at the XmlDocument.Imp ortNode() method. BTW, I kind of think
that you were getting away with something before when you just used
AppendChild(). As far as I know, you've always had to do something special
to bring in a node from another document. Right now I can't remember how it
was done with, say, MSXML2 or MSXML3, but I'm pretty sure that you had to do
something out of the ordinary.

Tom Dacon
Dacon Software Consulting

"Brian" <bo***@vafb.com > wrote in message
news:d2******** *************** ***@posting.goo gle.com...
Can someone show me how to append an XMLElement from one XMLDocument
as a child to an element in another XMLDocument? ( In one line of code
please )

I used to be able to say :

MyNode.AppendCh ild(OtherDoc.Do cumentElement)

No more in Dot Net.

TIA -
Brian

Nov 20 '05 #4
Now I am getting :

The node to be inserted is from a different document context.

With code :

importedNode = xDoc.ImportNode (xDoc.DocumentE lement, True)

Perhaps "DocumentElemen t" is not a good candidate for importing?

Brian

"Tom Dacon" <To**@t-dacons.com> wrote in message news:<eu******* ******@TK2MSFTN GP10.phx.gbl>.. .
Take a look at the XmlDocument.Imp ortNode() method. BTW, I kind of think
that you were getting away with something before when you just used
AppendChild(). As far as I know, you've always had to do something special
to bring in a node from another document. Right now I can't remember how it
was done with, say, MSXML2 or MSXML3, but I'm pretty sure that you had to do
something out of the ordinary.

Tom Dacon
Dacon Software Consulting

"Brian" <bo***@vafb.com > wrote in message
news:d2******** *************** ***@posting.goo gle.com...
Can someone show me how to append an XMLElement from one XMLDocument
as a child to an element in another XMLDocument? ( In one line of code
please )

I used to be able to say :

MyNode.AppendCh ild(OtherDoc.Do cumentElement)

No more in Dot Net.

TIA -
Brian

Nov 20 '05 #5
Think I have it now.
You must mention the 2 documents in the ImportNode call
i.e. importedNode=pa rentDoc.ImportN ode(xDoc.Select SingleNode("xml "), True)

Thanks for all your help guys!

Brian

"Tom Dacon" <To**@t-dacons.com> wrote in message news:<eu******* ******@TK2MSFTN GP10.phx.gbl>.. .
Take a look at the XmlDocument.Imp ortNode() method. BTW, I kind of think
that you were getting away with something before when you just used
AppendChild(). As far as I know, you've always had to do something special
to bring in a node from another document. Right now I can't remember how it
was done with, say, MSXML2 or MSXML3, but I'm pretty sure that you had to do
something out of the ordinary.

Tom Dacon
Dacon Software Consulting

"Brian" <bo***@vafb.com > wrote in message
news:d2******** *************** ***@posting.goo gle.com...
Can someone show me how to append an XMLElement from one XMLDocument
as a child to an element in another XMLDocument? ( In one line of code
please )

I used to be able to say :

MyNode.AppendCh ild(OtherDoc.Do cumentElement)

No more in Dot Net.

TIA -
Brian

Nov 20 '05 #6

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

Similar topics

8
3078
by: J Peterman | last post by:
Im having a nightmare trying to understand these nodes and linked lists. I've posted my code for my node.h, node.cpp, linkedlist.h and linkedlist.cpp files in separates replies. Can someone explain to me how I create a list and traverse it? In particular, how do I make use of the node.h method GetNext()? I don;t know what to do with it.
1
2978
by: Doug | last post by:
I need to compare two "address" structures within a document, and perform some action if they are not equal. The XML document is a purchase order, with an address at both the header and line item level: <Order> <Header> ... other header level stuff ... <Address>
5
1589
by: Claudio Jolowicz | last post by:
Suppose you have this document: <root> <node id="1"> <node id="4"/> <node id="5"/> </node> <node id="2"/> <node id="3"/> </root>
4
2125
by: Rolf Kemper | last post by:
Hi All, ned help on the example below. It works fine for msxml3/4 but has problems with saxon. Saxon complains "can not find matching function ..... " My target is to write style sheets usable for msxml3 , msxml4 , saxon .. Is there a general solution ?
1
2927
by: Ganesh Muthuvelu | last post by:
Hello all, I want to exclude one node (element alone) but copy all of the other elements. This is the XSLT I have. I want to exclude the "alias" element alone but it does not work.. Can somebody help? ************ <?xml version="1.0" ?> <xsl:stylesheet version="1.0"
3
5724
by: gregmcmullinjr | last post by:
Hi All, I would like to use XSLT to replace all <unodes that are children of a <bnode with a new <headingnode. Also, if the <bnode has no other children than remove it as well. For example: This would be some <b><u>Text</u></b>. It could <balso maybe be like <u>this</u>...</b>
3
2783
by: gregmcmullinjr | last post by:
I am spending alot of time on this group, lets see if we can figure this one out: I'm trying to determine if a node has any attributes at all. I would like to do a shallow copy (<xsl:copy>) if it does not, and a deep copy (<xsl:copy-of>) if it does. I've tried something like this: <xsl:template match="//content/*>
6
2018
by: Derek Hart | last post by:
I bring in an xml file into vb.net by using xmlDoc.LoadXml(XMLString) - I run xpath statements against the xml file to grab data from it, so I use, as an example, //Vehicles/Vehicles/@make to get the make of the car. But then I pass a specific node from xmlDoc into another function, not the whole xmlDoc, just a node from it. And if I run an xpath against it, I have to use .// (has a period at the beginning) so it does not grab info from...
1
1980
by: DR | last post by:
What is the fastest possible xsl style sheet to add another <boxnode under <boxes? <foo> <car></car> <boxes> <box id="234" /> <box id="75" /> </boxes> </foo>
0
9714
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
10599
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, 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...
0
10346
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10347
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
10090
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 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...
0
9173
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...
0
6863
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
5531
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...
3
3001
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.