VB.NET 9.0: XML Hole
I have discussed about the native XML support in VB.NET code editor in one of my BLOG posts. Now to generate a XML dynamically with values you can play with LINQ and project it to a XML.
Let us get the list of process running into my local machine with their thread count,
Dim query = From p In System.Diagnostics.Process.GetProcesses() _
Select New With _
.ProcessName = p.ProcessName, _
.ThreadCount = p.Threads.Count _
Structure of XML I want to create
<Process ThreadCount="2">Some Name</Process>
To generate XML you may have this code,
Dim _xml3 = _
<%= From p In System.Diagnostics.Process.GetProcesses() _
Select <Process ThreadCount=<%= p.Threads.Count %>><%= p.ProcessName %></Process> %>
Dim fileName As String = "C:\MyProcesses.xml"
Shell("notepad " + fileName, AppWinStyle.NormalFocus)
This will also save the XML in a file and you will find the XML header.