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

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 1793
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.ImportNode(big_xml.GetElementsByTagName( "node_tag_name").Item(0),
True)

small_xml.DocumentElement.AppendChild(result)

"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in message
news:88**********************************@microsof t.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.ImportNode(big_xml.GetElementsByTagName( "node_tag_name").Item(0),
True)

small_xml.DocumentElement.AppendChild(result)

"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in message
news:88**********************************@microsof t.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.ImportNode(big_xml.GetElementsByTagName( "small_xml").Item(0),
True)
small_xml.LoadXml("<small_xml>" & result.InnerXml & "</small_xml>")
"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in message
news:CA**********************************@microsof t.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.ImportNode(big_xml.GetElementsByTagName( "node_tag_name").Item(0),
True)

small_xml.DocumentElement.AppendChild(result)

"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in
message
news:88**********************************@microsof t.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
by: Christian Schmidbauer | last post by:
Hello! I prepare my XML document like this way: ------------------------------------------------------- PrintWriter writer; Document domDocument; Element domElement; // Root tag
2
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...
1
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...
9
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...
2
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...
4
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
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=""> -...
2
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...
4
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? ...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.