Is there a way to make an XMLDocument from a string? I want to do something like this
XMLDocument new parseDocumentFrom: '<root><child>wah</child></root>'
but #parseDocumentFrom: takes a stream as an argument. I tried creating a TextStream from the string, then a ReadStream on that, but that didn't work.
Thanks in advance for any help.
- Bob Erb
Bob,
I haven't use the XML libraries but I believe you could obtain the ReadStream from the String by sending #readStream which is understood by all SequenceableCollection subclasses.
XMLDOMParser parseDocumentFrom: '<root><child>wah</child></root>' readStream
You can also construct the ReadStream yourself from the String.
XMLDOMParser parseDocumentFrom: (ReadStream on: '<root><child>wah</child></root>')
In my image XMLDocument doesn't understand #parseDocumentFrom do I've used XMLDOMParser but I'm sure you get the picture.
I think TextStream is used for something completely different and is not needed here. I hope I've understood your question.
- Zulq.
Bob Erb wrote:
Is there a way to make an XMLDocument from a string? I want to do something like this
XMLDocument new parseDocumentFrom: '<root><child>wah</child></root>'
but #parseDocumentFrom: takes a stream as an argument.
squeak-dev@lists.squeakfoundation.org