473,386 Members | 1,698 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,386 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 1186

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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.