EDN Admin
Well-known member
I am trying to create an XML file from three sources. The main source is a table from SQL Server that I can parse the fields and place into my XDocument. I have two other sources of data I need to add to the document as well, both from other
sources. The format of the XML file is as follows:
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; <?<span style="color:#A31515; xml <span style="color:Red; version<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 1.0<span style="color:Black; "<span style="color:Blue; ?>
<span style="color:Blue; <<span style="color:#A31515; EPN<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Attributes<span style="color:Blue; >
EPN Specific attributes here from one datatable
<span style="color:Blue; </<span style="color:#A31515; Attributes<span style="color:Blue; >
I need to add this section from another table
<span style="color:Blue; <<span style="color:#A31515; AffectedProduct<span style="color:Blue; >
Data for the product from another datatable
<span style="color:Blue; </<span style="color:#A31515; AffectedProduct<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Operation<span style="color:Blue; >
Data for the operation from another datatable
<span style="color:Blue; </<span style="color:#A31515; Operation<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; EPN<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; xml<span style="color:Blue; >
[/code]
The Affected Products and Operations are two methods that return a List (of XElement) the method that generates the main XML shows a snipped below:
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; Shared <span style="color:Blue; Function Create EPNXML (<span style="color:Blue; ByVal EPNID <span style="color:Blue; as <span style="color:Blue; integer) <span style="color:Blue; as <span style="color:Blue; string
<span style="color:Blue; Dim myXML <span style="color:Blue; as <span style="color:Blue; New System.Xml.Linq.XDocument
<span style="color:Blue; Dim tempDT <span style="color:Blue; as DataTable
...
tempDT = GetEPN (EPNID) <span style="color:Green; Gets the data for the EPN
<span style="color:Blue; If tempDT.Rows.<span style="color:Blue; Count > 0 <span style="color:Blue; Then
<span style="color:Green; There should only be one row. Just in case there isnt generate
<span style="color:Green; multiple XML files
<span style="color:Blue; For <span style="color:Blue; Each dr <span style="color:Blue; As DataRow <span style="color:Blue; in tempDT.Rows
myxml = <?xml version=<span style="color:#A31515; "1.0"?>
<Attributes>
<span style="color:Green; Parse datatable field into individual tags
<EPNID><%= dr.Item(16).Value%></EPNID>
.....
</Attributes>
<span style="color:Green; I need to call the function here to get the list of XElements for the Affected Product
<span style="color:Green; I need to call the function here to get the list of XElements for the operation
</xml>
<span style="color:Green; Save XML file
<span style="color:Blue; Next
<span style="color:Blue; End <span style="color:Blue; If
<span style="color:Blue; End <span style="color:Blue; Function
[/code]
As you can see I need to call the two methods for the lists of XElements. What I need to know is how do I add the list of XElements to an XDocument?
Thanks.
View the full article
sources. The format of the XML file is as follows:
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; <?<span style="color:#A31515; xml <span style="color:Red; version<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 1.0<span style="color:Black; "<span style="color:Blue; ?>
<span style="color:Blue; <<span style="color:#A31515; EPN<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Attributes<span style="color:Blue; >
EPN Specific attributes here from one datatable
<span style="color:Blue; </<span style="color:#A31515; Attributes<span style="color:Blue; >
I need to add this section from another table
<span style="color:Blue; <<span style="color:#A31515; AffectedProduct<span style="color:Blue; >
Data for the product from another datatable
<span style="color:Blue; </<span style="color:#A31515; AffectedProduct<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Operation<span style="color:Blue; >
Data for the operation from another datatable
<span style="color:Blue; </<span style="color:#A31515; Operation<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; EPN<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; xml<span style="color:Blue; >
[/code]
The Affected Products and Operations are two methods that return a List (of XElement) the method that generates the main XML shows a snipped below:
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; Shared <span style="color:Blue; Function Create EPNXML (<span style="color:Blue; ByVal EPNID <span style="color:Blue; as <span style="color:Blue; integer) <span style="color:Blue; as <span style="color:Blue; string
<span style="color:Blue; Dim myXML <span style="color:Blue; as <span style="color:Blue; New System.Xml.Linq.XDocument
<span style="color:Blue; Dim tempDT <span style="color:Blue; as DataTable
...
tempDT = GetEPN (EPNID) <span style="color:Green; Gets the data for the EPN
<span style="color:Blue; If tempDT.Rows.<span style="color:Blue; Count > 0 <span style="color:Blue; Then
<span style="color:Green; There should only be one row. Just in case there isnt generate
<span style="color:Green; multiple XML files
<span style="color:Blue; For <span style="color:Blue; Each dr <span style="color:Blue; As DataRow <span style="color:Blue; in tempDT.Rows
myxml = <?xml version=<span style="color:#A31515; "1.0"?>
<Attributes>
<span style="color:Green; Parse datatable field into individual tags
<EPNID><%= dr.Item(16).Value%></EPNID>
.....
</Attributes>
<span style="color:Green; I need to call the function here to get the list of XElements for the Affected Product
<span style="color:Green; I need to call the function here to get the list of XElements for the operation
</xml>
<span style="color:Green; Save XML file
<span style="color:Blue; Next
<span style="color:Blue; End <span style="color:Blue; If
<span style="color:Blue; End <span style="color:Blue; Function
[/code]
As you can see I need to call the two methods for the lists of XElements. What I need to know is how do I add the list of XElements to an XDocument?
Thanks.
View the full article