473,657 Members | 2,579 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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("Bo oks>" +
"<Book><title>S ome book</title></Book>" +
"<Book><title>S ome other book</title></Book>"+
"</Books>");

XmlNode nodBook= doc.FirstChild. FirstChild;
XmlDocument docPart = new XmlDocument();
docPart.ImportN ode( 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 1205

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

Similar topics

2
6202
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 XmlNodeList nodeList = doc1.SelectNodes("//row"); foreach (XmlNode nodeCode in nodeList) { sb.Append(nodeCode.OuterXml);
5
17654
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 you do that? Regards Paw
2
4014
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 'EnrollmentState','SCGProductCollection' or 'EnrollmentEntities'. I have no idea how to parse following XML <SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
1
4292
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 become unacceptable. Performance improvment strategies I know of: 1. Switching to XMLReader
0
1052
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> <PrecioUnitario>10.4</PrecioUnitario> </Pedido> <Estado>Estado_0</Estado>
0
310
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> <Book> <Title>Some book</Title> </Book>
1
2941
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 XmlDocument.CreateElement("Q") method to create a "fake" or "Empty" XmlElement and set this element's OuterXml, but OuterXml is read only.
2
20489
by: Ramya A | last post by:
Hi, I have to create an XML in the following syntax: <RESPONSE> <QueueItems> <Node1>..... <Node2>..... </QueueItems> <QueueItems>
3
3902
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: <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> But when I save it : <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
0
8305
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,...
1
8503
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
7321
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
5632
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
4151
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...
0
4301
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
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
2
1950
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1607
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.