1

正如问题所述,我尝试使用XmlWriter定义为与共享文档站点相关联的 http 地址的目标。XmlWriter我将如何使用或不使用发送文件XmlWriter

    Dim resolver As XmlUrlResolver = New XmlUrlResolver()
    resolver.Credentials = CredentialCache.DefaultCredentials

    Dim doc As New XmlDocument
    doc.XmlResolver = resolver

    Dim feedWriter As XmlWriter = XmlWriter.Create("URL")

    Select Case format
        Case FeedFormats.Atom
            Response.ContentType = "application/rss+xml"

            Dim atomFormatter As New Atom10FeedFormatter(feed)
            atomFormatter.WriteTo(feedWriter)
        Case FeedFormats.Rss
            Response.ContentType = "application/atom+xml"

            Dim rssFormatter As New Rss20FeedFormatter(feed)
            rssFormatter.WriteTo(feedWriter)
    End Select

    doc.Save(feedWriter)

    feedWriter.Close()

这是一个片段,我没有添加我的案例或提要声明,但这是不必要的。我想这应该用输出流来完成,但我不知道该怎么做。

4

1 回答 1

1

以下是完全未经测试的:

Public Sub WriteXmlToUrl(url As Uri)
    Dim request AS HttpWebRequest = CTYPE(WebRequest.Create(url), HttpWebRequest)
    request.Method = "POST"
    request.ContentType = "application/xml"
    Using stream = request.GetRequestStream
        Using writer = XmlWriter.Create(stream)
            rem Write your Xml
        End Using
    End Using
End Sub
于 2013-05-30T22:01:16.427 回答