TDNeumann
Tue Apr 19 09:27:03 CDT 2005
Here is a rough outline of what I would like to do...
Public Function ProcessMessage(...) As XmlDocument
Dim coreStream As New MemoryStream
Dim XmlStreamWriter As New StreamWriter(coreStream,Text.Encoding.UTF8)
Dim XmlWriter As New XmlTextWriter(XmlStreamWriter)
Dim MyDocument as New XmlDocument
MyDocument = XmlBuilder(regexObject, elementCollection, XmlWriter)
End Function
Private Function XmlWriterXsdMultiLevel( _
ByVal regexObject As Regex, _
ByVal elementCollection As MatchCollection, _
ByVal XmlWriter As XmlTextWriter) As XmlDocument
...
... Build XmlContent from MatchCollection
...
XmlWriter.BaseStream.Position = 0
Dim TemporaryXmlDocument As New XmlDocument
TemporaryXmlDocument.Load(stream...)
XmlBuilder = TemporaryXmlDocument
.Close()
End Function
I think this represents what it is I want to do, though I am sure the
implementation is incorrect. Basically I need to be able to build an
in-memory Xml file and then copy that into an XmlDocument, with the end goal
of being able to use that with an xsd validator and then be able to
manipulate the contents of the document.
Thanks,
Tim
"Jon Skeet [C# MVP]" wrote:
> TDNeumann <TDNeumann@discussions.microsoft.com> wrote:
> > I am looking for examples that would illustrate something similar to the
> > following requirements:
> >
> > I am building an in-memory xml structure using the following as the setup
> > and classes to perform this step:
> >
> > If fileOutput Then
> > Dim XmlWriter As New XmlTextWriter("D:\QICS_MT\Debug Output\" & _
> > fileName, System.Text.Encoding.UTF8)
> > XmlWriterXsdMultiLevel(regexObject, _
> > elementCollection, _
> > XmlWriter)
> > Else
> > Dim coreStream As New MemoryStream
> > Dim XmlStreamWriter As New StreamWriter(coreStream,Text.Encoding.UTF8)
> > Dim XmlWriter As New XmlTextWriter(XmlStreamWriter)
> > XmlWriterXsdMultiLevel(regexObject, elementCollection, XmlWriter)
> > End If
> >
> > If I take the upper branch I can successfully create and write the document
> > and subsequently I can open the resulting Xml file and validate it against an
> > external xsd file.
> >
> > I would like to be able to take the lower branch and create the same xml
> > structure, yet in this instance I would like to be able to pass the created
> > xml content to an XmDocument class, so that I can pass and use it elsewhere
> > in the application.
> >
> > I am having problems understanding how to use the XmlDocument.Load(Stream)
> > method, though I believe this is how I should do this. I have not found many
> > examples of using this method, so I was looking for assistance in that area.
>
> Could you post a short but complete program which demonstrates the
> problem?
>
> See
http://www.pobox.com/~skeet/csharp/complete.html for details of
> what I mean by that.
>
> Note that if you're passing in a memory stream which has been written
> to, and you want to read the data which has been written, you'll need
> to position the stream back at the start, eg with
>
> stream.Position = 0
>
> --
> Jon Skeet - <skeet@pobox.com>
>
http://www.pobox.com/~skeet
> If replying to the group, please do not mail me too
>