-
Notifications
You must be signed in to change notification settings - Fork 0
Exploring_XML
Gathering of existing material ... to be moved to the tutorial.
Introduction https://wiki.squeak.org/squeak/1407
example
XMLDOMParser addressBookXMLWithDTD
XMLDOMParser parseDocumentFrom: XMLTokenizer addressBookXMLWithDTD readStream
https://wiki.squeak.org/squeak/6342
Cuis has xmlDocument topElement
while Squeak and Pharo have #root.
But that refers just to #topElement
https://wiki.squeak.org/squeak/6439
Squeak has an XML tutorial which explains how to access information in a rss page.
doc := HTTPClient httpGetDocument: 'http://source.squeak.org/trunk/feed.rss'.
XMLDOMParser parseDocumentFrom: (ReadStream on: (doc content)).
for more see Squeak 6.0. adapt it for Cuis; seems not to work; check again.
Lift out examples from Erudite https://github.com/Cuis-Smalltalk/Erudite
https://raw.githubusercontent.com/Cuis-Smalltalk/Erudite/refs/heads/master/Examples/xmlbook3.xml Add the statement which reads this here
https://wiki.squeak.org/squeak/6342
(XMLDOMParser parseFileNamed: 'fao_country_names.xml')
firstNode
allElementsSelect: [ : each |
each localName = 'geographical_region' ].
The file fao_country_names.xml seems to be no longer available in XML, see https://data.apps.fao.org/catalog/dataset/country-names
Find another example which uses allElementsSelect:
From Pharo examples https://github.com/pharo-contributions/XML-XMLParser
|xmlString|
xmlString := '<?xml version="1.0" encoding="UTF-8"?>
<countries>
<country code="af" handle="afghanistan" continent="asia" iso="4">Afghanistan</country>
<country code="al" handle="albania" continent="europe" iso="8">Albania</country>
<country code="dz" handle="algeria" continent="africa" iso="12">Algeria</country>
</countries>'.
"adapted for Cuis"
XMLDOMParser parseDocumentFrom: xmlString readStream
The Cuis YAXO version does not have the Pharo XPath access. That is however in a separate Library: https://github.com/pharo-contributions/XML-XPath For more see the Pharo XPath booklet.
13 year old Pharo video https://www.youtube.com/watch?v=6q78hzawfGU
Tune: Mary had a little lamb
MusicXML notation
https://musescore.com/user/34504790/scores/6127202 Clicking the download button offers to download it in MusicXML.
https://abcnotation.com/tunePage?a=trillian.mit.edu/~jc/music/abc/mirror/back.numachi.com/Frere_Jacques/0000 MusicXML https://abcnotation.com/getResource/downloads/code_/frere-jacques.xml?a=back.numachi.com:8000/dtrad/abc_dtrad.tar.gz/abc_dtrad/FRERJACQ/0000
Next thing to do: Finalize the MusicXML example Frere Jacques : play it with correct duration.