direct edit of the ii6s metabase.xml using c# or vb.net

R

Roger

I need to edit the IIS 6.0 config file (metabase.xml) and had a go with this
code, trying to get a list of all defined websites, and write their name to
console, but it does not seem to work, would appreciate any pointers:

-----------
Try
Dim doc As New XmlDocument
Dim nodelist As XmlNodeList
Dim node As XmlNode

'Load the Xml file
'doc.Load("c:\windows\system32\inetsrv\metabase.xml")

'Get the list of name nodes

nodelist = doc.SelectNodes("/MBProperty/IIsWebServer")

'Loop through the nodes

For Each node In nodelist
Dim siteName =
node.Attributes.GetNamedItem("ServerComment").Value
Console.WriteLine("Site: " & siteName)
Next

Catch errorVariable As Exception
'Error trapping
Console.Write(errorVariable.ToString())
End Try
 
C

Cor

Hi Roger,

Will this work for you?

(I would put on Option Strict On if I was you, there where some little
errors, but had nothing to do with this.)

Cor

\\\
Dim doc As New Xml.XmlDocument
Dim nodelist As Xml.XmlNodeList
Dim node As Xml.XmlNode
'Load the Xml file
doc.Load("c:\test\metabase.xml")
'Get the list of name nodes
nodelist = doc.GetElementsByTagName("IIsWebServer")
'Loop through the nodes
For Each node In nodelist
Dim siteName As String =
node.Attributes.GetNamedItem("ServerComment").Value()
MessageBox.Show("Site: " & siteName)
Next
///
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top