Is there anyway i can call orderedFiles in my asp xml tags so that it displays the file associated with orderedFiles?
EDIT
Is it possible to replace the current filepath with a value in an xml document?
You can use databinding to set the value of the DocumentSource property at databind-time. First, in your code-behind, create a public or protected method that returns a string that contains the physical path to the file you want to display. In your case, this method would have the three lines of code you listed, and would return orderedFiles.FullName, which is the physical path to the newest file. Let's say this method is called "GetFile()", and it should look something like this:
Public Function GetFile() As String
Dim di As New DirectoryInfo("C:\Users\Simon\Desktop\XML Logs\")
Dim files As FileSystemInfo() = di.GetFileSystemInfos()
Dim newestFile = files.OrderByDesc(Function(f) f.CreationTime).First
Return newestFile.FullName
End Sub
Then In your markup, use databinding syntax to assign the DocumentSource property to the output of this method call:
<asp:Xml ID="xmlControl" runat="server" DocumentSource='<%# GetFile() %>' />
Finally, you will need to make sure you kick off databinding on the page by calling Page.DataBind() at some point in your page load method.
If you want a good introduction to databinding, you can see this article by Dino Esposito