473,396 Members | 1,865 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,396 software developers and data experts.

Create XmlDocument from subset of another

Hi all,

I'm trying to efficiently pull data out of an xml file into a XmlDocument
AND create another "sub" document based on one subtree of the document. For
example, say I've got:

<Books>
<Book>
<Title>Some book</Title>
</Book>
<Book>
<Title>Some other book</Title>
</Book>
<Books>

So far I've tried things like:

XmlDocument doc = new XmlDocument();
doc.LoadXml("Books>" +
"<Book><title>Some book</title></Book>" +
"<Book><title>Some other book</title></Book>"+
"</Books>");

XmlNode nodBook= doc.FirstChild.FirstChild;
XmlDocument docPart = new XmlDocument();
docPart.ImportNode( nodBook, true );
However, docPart only winds up as null. I've tried variations on the
ImportNode theme and received errors relating to the context being wrong for
the node.

Any pointers on create a sub-XmlDocument from an existing XmlDocument?

Thanks,

John
Jul 21 '05 #1
0 1187

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

Similar topics

2
by: Dave | last post by:
Hi, Is there an easier way to pull a subset of nodes from one XmlDocument to another? I have the code below but would like to know if there is a more streamlined method. Thanks, Dave ...
5
by: Paw Pedersen | last post by:
Is it possible to load a XSD and loop throw the nodes and attributes that you whant filled out, and then generate a XML instance with the trees and data that you have filled data in? And how do...
2
by: John Barring | last post by:
Hi All, I am new to XPath stuff. I want parse XMLDocument with XPath and find out subset of information. If you look at following xml, for i.e how can i retrieve subset information such as...
1
by: John A Grandy | last post by:
I've got an app that has hundreds of medium-sized (100s of elements) XML files on disk (not in db). Right now these are loaded via XMLDocument.Load and searched with XPATH. The performance has...
0
by: Luis Esteban Valencia | last post by:
Hello. I got this message <ns0:Orden xmlns:ns0="http://localhost/CreditCheck"> <IdCliente>10</IdCliente> - <Pedido> <IdProducto>IdProducto_0</IdProducto> <Cantidad>10.4</Cantidad>...
0
by: John Spiegel | last post by:
Hi all, I'm trying to efficiently pull data out of an xml file into a XmlDocument AND create another "sub" document based on one subtree of the document. For example, say I've got: <Books>...
1
by: Ryan Liu | last post by:
Hi, I know I need create a DataRow from a DataTable for the schema reason. Why must I create a XmlElement in a XmlDocument? I already have a string, I was trying to use...
2
by: Ramya A | last post by:
Hi, I have to create an XML in the following syntax: <RESPONSE> <QueueItems> <Node1>..... <Node2>..... </QueueItems> <QueueItems>
3
by: Stephen Ward | last post by:
I have a simple little project open a xml file change a few nodes save the file, no big deal. The problem is that the doctype is getting modified when I save the file. So it looks like this:...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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,...

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.