views:

609

answers:

5

Sander, has wrote a related article for this...

http://todotnet.com/archive/2005/10/11/2595.aspx

unfortunately the code is in C#.

Which is the equivelant to the vb.net version?

+1  A: 

Converted with http://www.developerfusion.com/tools/convert/csharp-to-vb/

Imports System.Net
Imports System.Xml.Xsl  
Imports System.Net

Dim request As HttpWebRequest = DirectCast(HttpWebRequest.Create("...url to the original publish.htm file..."), HttpWebRequest)
Dim response As HttpWebResponse = DirectCast(request.GetResponse(), HttpWebResponse)
Dim dataStream As Stream = response.GetResponseStream()
Dim reader As New StreamReader(dataStream)
Dim responseFromServer As String = reader.ReadToEnd()

responseFromServer = responseFromServer.Replace(" ", " ")

Dim xml As New System.Xml.XmlDocument()
xml.LoadXml(responseFromServer)

Dim xslt As New XslCompiledTransform()
Dim html As TextWriter = New StringWriter()
xslt.Load(Server.MapPath("CustomPublish.xsl"))
xslt.Transform(xml, Nothing, html)

Response.Write(html.ToString())
Response.[End]()

Let me know if it works.

belaz
A: 

curly lines are shown in...

HttpWebRequest 'type is not defined'

HttpWebResponse 'type is not defined'

Chocol8
Either fully qualify the names (System.Net.HttpWebRequest) or import the System.Net namespace.
whatknott
A: 
Imports System.IO
Imports System.Xml.Xsl
Imports System.Net

Dim request As HttpWebRequest = DirectCast(Net.WebRequest.Create("http://www.myurl"), HttpWebRequest)
Dim response As HttpWebResponse = DirectCast(request.GetResponse(), HttpWebResponse)
Dim dataStream As Stream = response.GetResponseStream()
Dim reader As New StreamReader(dataStream)
Dim responseFromServer As String = reader.ReadToEnd()
responseFromServer = responseFromServer.Replace(" ", " ")
Dim xml As New System.Xml.XmlDocument()
xml.LoadXml(responseFromServer)
Dim xslt As New XslCompiledTransform()
Dim html As TextWriter = New StringWriter()
xslt.Load(Server.MapPath("CustomPublish.xsl"))
xslt.Transform(xml, Nothing, html)
response.Write(html.ToString())
response.End()

...one line before end i get, "write is not a member of system.net.httpwebresponse"

...and in the last line i get "end is not a member of system.net.httpwebresponse"

Thank you for your time

Chocol8
A: 
Response.Write(html.ToString())

Capitalize.

Please comment answers and check best answer, so we can keep in touch.

belaz
A: 

after capitalizing the situation got better but now i get the error

The '=' character, hexadecimal value 0x3D, cannot be included in a name

in the line xml.LoadXml(responseFromServer)

any further ideas? I am stackoverflow with this one!

Chocol8