Home > LINQ, VB.NET > Dynamicaly create XML Elements in XML Literals

Dynamicaly create XML Elements in XML Literals

XML Literals

d is a Class that has a Fuction named GetXMLFilenames defined.
GetXMLFilenames returns a List(Of XElements).


Dim _XMLDoc = <OBJECT>
  <OBJTYPE>0</OBJTYPE>
  <PAGES><%= d.PageCount %></PAGES>
  <%= From elem In d.GetXMLFilenames Select
     New XElement(elem.Name, elem.Value)
  %>
</OBJECT>
  
   Public Function GetXMLFilenames() As List(Of XElement)
      Try
         Dim tempstr As String = ""
         Dim _XElementList As New List(Of XElement)

         Dim _i As Integer = 0
         For Each _Filename In _Filenames
            _i += 1
            Dim _XElement As New XElement("FILE" &amp; _i, _Filename)
            _XElementList.Add(_XElement)
         Next
         Return _XElementList

      Catch ex As Exception
         Throw ex
      End Try
   End Function

Advertisements
Categories: LINQ, VB.NET Tags:
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: