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,
Original LINQ
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
<Processes>
<Process ThreadCount="2">Some Name</Process>
</Processes>
To generate XML you may have this code,
Dim _xml3 = _
<Processes>
<%= From p In System.Diagnostics.Process.GetProcesses() _
Select <Process ThreadCount=<%= p.Threads.Count %>><%= p.ProcessName %></Process> %>
</Processes>
Console.WriteLine(_xml)
Dim fileName As String = "C:\MyProcesses.xml"
_xml3.Save(fileName)
Shell("notepad " + fileName, AppWinStyle.NormalFocus)
This will also save the XML in a file and you will find the XML header.
Namoskar!!!
Comments
- Anonymous
February 07, 2008
The comment has been removed - Anonymous
February 07, 2008
I have discussed about the native XML support in VB.NET code editor in one of my BLOG posts. Now to generate