473,785 Members | 2,798 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Extract a <node> as a new XMLDocument?

Hello,

Would you tell me if there is a way to extract a single node as a new
xmldocument?

Thanks.
Jan 19 '06 #1
4 1815
Carlos,
You would need to :
1) Create a new XmlDocument.
2) use the ImportNode method to bring in the node from the other XmlDocument.

See MSDN Library Help or online for code samples.

Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Carlos Albert" wrote:
Hello,

Would you tell me if there is a way to extract a single node as a new
xmldocument?

Thanks.

Jan 19 '06 #2
Tnx, but I tried to do this and I'm doing something very wrong (cause it
doesn't work at all):

Dim big_xml As New XmlDocument

big_xml.LoadXml (xml)

Dim small_xml As New XmlDocument

Dim result As XmlNode =
small_xml.Impor tNode(big_xml.G etElementsByTag Name("node_tag_ name").Item(0),
True)

small_xml.Docum entElement.Appe ndChild(result)

"Peter Bromberg [C# MVP]" <pb*******@yaho o.nospammin.com > wrote in message
news:88******** *************** ***********@mic rosoft.com...
Carlos,
You would need to :
1) Create a new XmlDocument.
2) use the ImportNode method to bring in the node from the other
XmlDocument.

See MSDN Library Help or online for code samples.

Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Carlos Albert" wrote:
Hello,

Would you tell me if there is a way to extract a single node as a new
xmldocument?

Thanks.

Jan 19 '06 #3
Break up your code into smaller pieces so it's easier to see what is happening
on each line with debugger step-through.
Also, ensure the new document has the correct processing instruction, root
element, etc. to be valid.
Also, it looks to me like you are trying to import your node from the new
document instead of the original!

Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Carlos Albert" wrote:
Tnx, but I tried to do this and I'm doing something very wrong (cause it
doesn't work at all):

Dim big_xml As New XmlDocument

big_xml.LoadXml (xml)

Dim small_xml As New XmlDocument

Dim result As XmlNode =
small_xml.Impor tNode(big_xml.G etElementsByTag Name("node_tag_ name").Item(0),
True)

small_xml.Docum entElement.Appe ndChild(result)

"Peter Bromberg [C# MVP]" <pb*******@yaho o.nospammin.com > wrote in message
news:88******** *************** ***********@mic rosoft.com...
Carlos,
You would need to :
1) Create a new XmlDocument.
2) use the ImportNode method to bring in the node from the other
XmlDocument.

See MSDN Library Help or online for code samples.

Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Carlos Albert" wrote:
Hello,

Would you tell me if there is a way to extract a single node as a new
xmldocument?

Thanks.


Jan 19 '06 #4
Made it work, thanks! =)

Dim big_xml As New XmlDocument
big_xml.LoadXml (xml)
Dim small_xml As New XmlDocument
Dim result As XmlNode
result =
small_xml.Impor tNode(big_xml.G etElementsByTag Name("small_xml ").Item(0),
True)
small_xml.LoadX ml("<small_xml> " & result.InnerXml & "</small_xml>")
"Peter Bromberg [C# MVP]" <pb*******@yaho o.nospammin.com > wrote in message
news:CA******** *************** ***********@mic rosoft.com...
Break up your code into smaller pieces so it's easier to see what is
happening
on each line with debugger step-through.
Also, ensure the new document has the correct processing instruction, root
element, etc. to be valid.
Also, it looks to me like you are trying to import your node from the new
document instead of the original!

Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Carlos Albert" wrote:
Tnx, but I tried to do this and I'm doing something very wrong (cause it
doesn't work at all):

Dim big_xml As New XmlDocument

big_xml.LoadXml (xml)

Dim small_xml As New XmlDocument

Dim result As XmlNode =
small_xml.Impor tNode(big_xml.G etElementsByTag Name("node_tag_ name").Item(0),
True)

small_xml.Docum entElement.Appe ndChild(result)

"Peter Bromberg [C# MVP]" <pb*******@yaho o.nospammin.com > wrote in
message
news:88******** *************** ***********@mic rosoft.com...
> Carlos,
> You would need to :
> 1) Create a new XmlDocument.
> 2) use the ImportNode method to bring in the node from the other
> XmlDocument.
>
> See MSDN Library Help or online for code samples.
>
> Peter
>
> --
> Co-founder, Eggheadcafe.com developer portal:
> http://www.eggheadcafe.com
> UnBlog:
> http://petesbloggerama.blogspot.com
>
>
>
>
> "Carlos Albert" wrote:
>
>> Hello,
>>
>> Would you tell me if there is a way to extract a single node as a new
>> xmldocument?
>>
>> Thanks.
>>
>>
>>


Jan 20 '06 #5

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

Similar topics

1
6828
by: Christian Schmidbauer | last post by:
Hello! I prepare my XML document like this way: ------------------------------------------------------- PrintWriter writer; Document domDocument; Element domElement; // Root tag
2
10568
by: Donald Firesmith | last post by:
I am having trouble having Google Adsense code stored in XSL converted properly into HTML. The <> unfortunately become &lt; and &gt; and then no longer work. XSL code is: <script type="text/javascript"> <!]> </script> <script type="text/javascript"
1
3646
by: Casper B | last post by:
As the topic says, I am wondering how (in Java) I can extract a sub-tree of a org.w3c.dom.Document and form a brand new one. I use Oracle's XMLDocument implementation and have been playing around with DocumentFragment etc. but somehow I always end up creating only the single node and not its sub-nodes. /Casper
9
6844
by: Wang, Jay | last post by:
Hello, all, I would like to enable some text between <SPAN url="http://www.testserver.com/">WORD TO BE DRAGGED </SPAN>. I put some javascript and it will extract http://www.testserver.com/ from the the span element when I select the whole text in the SPAN and drag it. However, I want to drag it without have to select the words between the span element. The default mouse action will only select the words when i move the mouse. Can...
2
2454
by: bissatch | last post by:
Hi, I am currently writing a simple PHP program that uses an XML file to output rows for a 'Whats New' page. Once written, I will only require updating the XML file and any pages that use the XML file will get their row content from there. The rows may look some thing similar to this: - Added <a>mailing list</a> functionality to <a>homepage</a> - Competition winners announced, click <a>here</a>
4
5990
by: Victor Hadianto | last post by:
Hi, If I have an XmlDocument DOM how do I insert <?mso-application progid="ProgId.Here"?> programmatically? -- Victor Hadianto http://www.synop.com/Products/SauceReader/
2
2141
by: hharry | last post by:
Hello All, I have the following xml file: which I read into a string (sXML) <?xml version="1.0" ?> - <BackgroundReports xmlns="http://ns.hr-xml.org/2004-08-02" userId="" password=""> - <BackgroundReportPackage type="report"> - <ProviderReferenceId> <IdValue>7173511</IdValue>
2
1396
by: David Thielen | last post by:
Hi; I have a node where it is "<w:t> </w:t>" and what I get from XmlTextReader is Element, SignificantWhitespace, EndElement instead of Element, Text, EndElement. Question 1 is why? The text of that node is a space. Question 2 is how do I handle this. Do I watch for a SignificantWhitespace inside an Element/EndElement? Or will that get me other things too?
4
27212
by: rrayfield | last post by:
I have a XML file that contains content for an asp.net website. I need the quickest way to find the node and write the elements out to the page. Also how would I get the links section out of it? do I have to loop through them? Example = I need the content for the Home Page, and I have the id=Home in the xml, how do I get the rest of the data to write out to the page in that node between <page id="Home"> and </page> <?xml version="1.0"...
0
9645
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
9481
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,...
0
10155
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
10095
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
8978
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
6741
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
5383
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...
2
3655
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2881
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.