Hello Cerebrus:
I like to use the technique you mentioned.
Here's what I did and i have to follow this....
Private Sub Test1()
Dim writer As New XmlTextWriter("C:\MusaBiralo.xml",
System.Text.Encoding.UTF8)
writer.WriteStartElement("Level0")
Test2()
writer.WriteEndElement()
Wnd Sub
Private Sub Test2()
dim xDoc = XDocument.Load(Path.GetTempPath & "Temp.xml")
Dim elements = From element In xDocTank.Descendants
("PhysicalDataSheet") _
Where element.Attribute("PhysicalRecordSheetID") = "" _
Select element
Dim inners = From inner In elements _
Select inner.Nodes
'Need help here???
'how can write my inners Nodes to the 'writer'.
'I have to send it through writer... :(
'Thanks for you help.
End Sub
On Aug 25, 2:46 am, Cerebrus <[email protected]> wrote:
> Numerous ways to do it. Probably the simplest might be written using
> Query expression syntax :
>
> ---
> using System.Xml.Linq;
> using System.Collections.Generic;
>
> public static void CopyChildNodes()
> {
> XDocument doc1 = XDocument.Load("Test.xml");
> IEnumerable<XElement> elements =
> from el in doc1.Element("Node").Elements("Element")
> select el;
>
> XDocument doc2 = new XDocument(
> new XDeclaration("1.0", "utf-8", "yes"),
> new XElement("RootNode", elements)
> );
>
> doc2.Save("Test2.xml");}
>
> ---
>
> On Aug 25, 2:50 am, "musa.biralo" <[email protected]> wrote:
>
> > Hi there,
>
> > I have to copy all elements that are within certain node to another
> > xml file. Here's an example,
>
> > <Node>
> > <Element ID = "1" Attribute="value1" \>
> > <Element ID = "2" Attribute="value2" \>
> > .... 1000's of lines...so i like to copy them all
> > <Element ID = "3" Attribute="value3" \>
> > </Node>
>
> > I want to copy(or transfer) everything that are with in <Node></Node>
> > and put it over to other XML file. I could not figure out how. Could
> > you please lead to a weblink or help me out.
>
> > Thanks in advance.
> > Musa.Biralo
>
>