Greetings community of pharo I have to process many XML files, to convert them to objects and incorporate them into a database and create an application in seaside. In pharo I have found XmlParser, however I have not found documentation to use it as best as possible. I do not know if there is another more appropriate tool. Please if possible and there are examples of common use of xml processing inform me. Thank you very much in advance Oswall
Am 10.07.2018 um 23:51 schrieb oswall arguedas:
Greetings community of pharo
I have to process many XML files, to convert them to objects and incorporate them into a database and create an application in seaside.
In pharo I have found XmlParser, however I have not found documentation to use it as best as possible. I do not know if there is another more appropriate tool. Please if possible and there are examples of common use of xml processing inform me.
Thank you very much in advance Oswall
Hello, as always in small talk: look at the code (code and test cases). There are some individual documents on the subject of XML, but to my knowledge there is no all-encompassing paper that covers everything about XML. E.g. you find a paper about XPath <https://files.pharo.org/books-pdfs/booklet-Scraping/2017-09-29-scrapingbook....>. The author of the XML libraries available in Pharo is Monty and has a blog here: <https://montyos.wordpress.com/>. If you want to delve deeper into the topic, I would read Monty's entries in the Pharo specific mailing lists. I'm sure you can learn a lot here. He is very competent and helpful. <http://forum.world.st/template/NamlServlet.jtp?macro=search_page&node=129479...> searches all entries of monty in the last 600 days. HTH, Franz Josef
This is the latest version of the XML/XPath Scraping Booklet: <https://files.pharo.org/books-pdfs/booklet-Scraping/2018-01-07-scrapingbook....> ___ montyos.wordpress.com
Thanks Franz and Monty. I'm working on it, everything is going very well. The feedback when I master it. Oswall ________________________________ De: Pharo-users <pharo-users-bounces@lists.pharo.org> en nombre de monty <monty2@programmer.net> Enviado: miércoles, 11 de julio de 2018 03:32:35 Para: pharo-users@lists.pharo.org Asunto: Re: [Pharo-users] XML support for pharo This is the latest version of the XML/XPath Scraping Booklet: <https://files.pharo.org/books-pdfs/booklet-Scraping/2018-01-07-scrapingbook....> ___ montyos.wordpress.com
Thanks Franz and Monty. I'm working on it, everything is going very well. The feedback when I master it. Oswall ________________________________ De: Pharo-users <pharo-users-bounces@lists.pharo.org> en nombre de monty <monty2@programmer.net> Enviado: miércoles, 11 de julio de 2018 03:32 Para: pharo-users@lists.pharo.org Asunto: Re: [Pharo-users] XML support for pharo This is the latest version of the XML/XPath Scraping Booklet: <https://files.pharo.org/books-pdfs/booklet-Scraping/2018-01-07-scrapingbook....> Scraping HTML with XPath - files.pharo.org<https://files.pharo.org/books-pdfs/booklet-Scraping/2018-01-07-scrapingbook....> files.pharo.org 1.6 Alargeexample ⢠Siblings.Siblingsarechildnodesthathavethesameparent.Thecard-name,types,year,rarity,expansionandcardtextelementsareallsib- ___ montyos.wordpress.com
Regards, I practice with the example of the book. I can not read the atomic values of the nodes. For example, with this piece of the example: <cardset> <card> <cardname lang = "en"> Arcane Lighthouse </ cardname> <types> Land </ types> <year> 2014 </ year> To get the atomic value of the node year and assign it to the variable yearmem, I do it like this: yearmem: = tree xpath: '/ cardset / card / year'. But it fails. How do I get the 2014 value? Thank you Oswall ________________________________ De: Pharo-users <pharo-users-bounces@lists.pharo.org> en nombre de oswall arguedas <oswallcr@hotmail.com> Enviado: miércoles, 11 de julio de 2018 20:17:55 Para: pharo-users@lists.pharo.org Asunto: Re: [Pharo-users] XML support for pharo Thanks Franz and Monty. I'm working on it, everything is going very well. The feedback when I master it. Oswall ________________________________ De: Pharo-users <pharo-users-bounces@lists.pharo.org> en nombre de monty <monty2@programmer.net> Enviado: miércoles, 11 de julio de 2018 03:32 Para: pharo-users@lists.pharo.org Asunto: Re: [Pharo-users] XML support for pharo This is the latest version of the XML/XPath Scraping Booklet: <https://files.pharo.org/books-pdfs/booklet-Scraping/2018-01-07-scrapingbook....> Scraping HTML with XPath - files.pharo.org<https://files.pharo.org/books-pdfs/booklet-Scraping/2018-01-07-scrapingbook....> files.pharo.org 1.6 Alargeexample ⢠Siblings.Siblingsarechildnodesthathavethesameparent.Thecard-name,types,year,rarity,expansionandcardtextelementsareallsib- ___ montyos.wordpress.com
Hi Oswall What sort of failure did you get? It helps with this sort of thing to execute the code in a playground and inspect the result. One thing you need to know is that the result of xpath is almost always some sort of XMLCollection, even when there is only one element. I would expect the result you want if you write yearmem := (tree xpath: Âcardset/card/yearÂ) first. Note that you should not need a slash at the start; xpath starts searching in the children of the top node. Also you do not need to give every step of the hierarchy; you can always skip levels provided the result specifies a unique route to the node you want. So in this case you can write: yearmem := (tree xpath: Â//yearÂ) first. Hope this helps Peter Kenny From: Pharo-users <pharo-users-bounces@lists.pharo.org> On Behalf Of oswall arguedas Sent: 12 July 2018 17:09 To: pharo-users@lists.pharo.org Subject: Re: [Pharo-users] XML support for pharo Regards, I practice with the example of the book. I can not read the atomic values of the nodes. For example, with this piece of the example: <cardset> <card> <cardname lang = "en"> Arcane Lighthouse </ cardname> <types> Land </ types> <year> 2014 </ year> To get the atomic value of the node year and assign it to the variable yearmem, I do it like this: yearmem: = tree xpath: '/ cardset / card / year'. But it fails. How do I get the 2014 value? Thank you Oswall _____ De: Pharo-users <pharo-users-bounces@lists.pharo.org <mailto:pharo-users-bounces@lists.pharo.org> > en nombre de oswall arguedas <oswallcr@hotmail.com <mailto:oswallcr@hotmail.com> > Enviado: miércoles, 11 de julio de 2018 20:17:55 Para: pharo-users@lists.pharo.org <mailto:pharo-users@lists.pharo.org> Asunto: Re: [Pharo-users] XML support for pharo Thanks Franz and Monty. I'm working on it, everything is going very well. The feedback when I master it. Oswall _____ De: Pharo-users <pharo-users-bounces@lists.pharo.org <mailto:pharo-users-bounces@lists.pharo.org> > en nombre de monty <monty2@programmer.net <mailto:monty2@programmer.net> > Enviado: miércoles, 11 de julio de 2018 03:32 Para: pharo-users@lists.pharo.org <mailto:pharo-users@lists.pharo.org> Asunto: Re: [Pharo-users] XML support for pharo This is the latest version of the XML/XPath Scraping Booklet: <https://files.pharo.org/books-pdfs/booklet-Scraping/2018-01-07-scrapingbook .pdf> <https://files.pharo.org/books-pdfs/booklet-Scraping/2018-01-07-scrapingbook .pdf> Scraping HTML with XPath - files.pharo.org files.pharo.org 1.6 Alargeexample  Siblings.Siblingsarechildnodesthathavethesameparent.Thecard-name,types,year, rarity,expansionandcardtextelementsareallsib- ___ montyos.wordpress.com
Hello Peter, Thanks for your help. The value I get is: <year> 2014 </ year> What I need is to extract the atomic value of the node, which is: 2014 To assign it to variables and create objects. I can not find how to obtain that punctual value 2014. The main purpose is to read many xml files and create smalltak objects with that data, then save them in DB and process the data. ________________________________ De: Pharo-users <pharo-users-bounces@lists.pharo.org> en nombre de PBKResearch <peter@pbkresearch.co.uk> Enviado: jueves, 12 de julio de 2018 11:17:41 Para: 'Any question about pharo is welcome' Asunto: Re: [Pharo-users] XML support for pharo Hi Oswall What sort of failure did you get? It helps with this sort of thing to execute the code in a playground and inspect the result. One thing you need to know is that the result of xpath is almost always some sort of XMLCollection, even when there is only one element. I would expect the result you want if you write yearmem := (tree xpath: âcardset/card/yearâ) first. Note that you should not need a slash at the start; xpath starts searching in the children of the top node. Also you do not need to give every step of the hierarchy; you can always skip levels provided the result specifies a unique route to the node you want. So in this case you can write: yearmem := (tree xpath: â//yearâ) first. Hope this helps Peter Kenny From: Pharo-users <pharo-users-bounces@lists.pharo.org> On Behalf Of oswall arguedas Sent: 12 July 2018 17:09 To: pharo-users@lists.pharo.org Subject: Re: [Pharo-users] XML support for pharo Regards, I practice with the example of the book. I can not read the atomic values of the nodes. For example, with this piece of the example: <cardset> <card> <cardname lang = "en"> Arcane Lighthouse </ cardname> <types> Land </ types> <year> 2014 </ year> To get the atomic value of the node year and assign it to the variable yearmem, I do it like this: yearmem: = tree xpath: '/ cardset / card / year'. But it fails. How do I get the 2014 value? Thank you Oswall ________________________________ De: Pharo-users <pharo-users-bounces@lists.pharo.org<mailto:pharo-users-bounces@lists.pharo.org>> en nombre de oswall arguedas <oswallcr@hotmail.com<mailto:oswallcr@hotmail.com>> Enviado: miércoles, 11 de julio de 2018 20:17:55 Para: pharo-users@lists.pharo.org<mailto:pharo-users@lists.pharo.org> Asunto: Re: [Pharo-users] XML support for pharo Thanks Franz and Monty. I'm working on it, everything is going very well. The feedback when I master it. Oswall ________________________________ De: Pharo-users <pharo-users-bounces@lists.pharo.org<mailto:pharo-users-bounces@lists.pharo.org>> en nombre de monty <monty2@programmer.net<mailto:monty2@programmer.net>> Enviado: miércoles, 11 de julio de 2018 03:32 Para: pharo-users@lists.pharo.org<mailto:pharo-users@lists.pharo.org> Asunto: Re: [Pharo-users] XML support for pharo This is the latest version of the XML/XPath Scraping Booklet: <https://files.pharo.org/books-pdfs/booklet-Scraping/2018-01-07-scrapingbook....> Scraping HTML with XPath - files.pharo.org<https://files.pharo.org/books-pdfs/booklet-Scraping/2018-01-07-scrapingbook....> files.pharo.org 1.6 Alargeexample ⢠Siblings.Siblingsarechildnodesthathavethesameparent.Thecard-name,types,year,rarity,expansionandcardtextelementsareallsib- ___ montyos.wordpress.com
Hi Oswall Well, you have located the correct node, which is some kind of XMLNode, so all you need is to access its content. If you browse the class and look at its Âaccessing protocol, you see the method XMLNode>>#contentString, which will give you, in your test case, Â2014 as a string. If you want to enter it in the database as a number, asNumber will do that HTH Peter Kenny From: Pharo-users <pharo-users-bounces@lists.pharo.org> On Behalf Of oswall arguedas Sent: 12 July 2018 18:35 To: 'Any question about pharo is welcome' <pharo-users@lists.pharo.org> Subject: Re: [Pharo-users] XML support for pharo Hello Peter, Thanks for your help. The value I get is: <year> 2014 </ year> What I need is to extract the atomic value of the node, which is: 2014 To assign it to variables and create objects. I can not find how to obtain that punctual value 2014. The main purpose is to read many xml files and create smalltak objects with that data, then save them in DB and process the data. _____ De: Pharo-users <pharo-users-bounces@lists.pharo.org <mailto:pharo-users-bounces@lists.pharo.org> > en nombre de PBKResearch <peter@pbkresearch.co.uk <mailto:peter@pbkresearch.co.uk> > Enviado: jueves, 12 de julio de 2018 11:17:41 Para: 'Any question about pharo is welcome' Asunto: Re: [Pharo-users] XML support for pharo Hi Oswall What sort of failure did you get? It helps with this sort of thing to execute the code in a playground and inspect the result. One thing you need to know is that the result of xpath is almost always some sort of XMLCollection, even when there is only one element. I would expect the result you want if you write yearmem := (tree xpath: Âcardset/card/yearÂ) first. Note that you should not need a slash at the start; xpath starts searching in the children of the top node. Also you do not need to give every step of the hierarchy; you can always skip levels provided the result specifies a unique route to the node you want. So in this case you can write: yearmem := (tree xpath: Â//yearÂ) first. Hope this helps Peter Kenny From: Pharo-users <pharo-users-bounces@lists.pharo.org <mailto:pharo-users-bounces@lists.pharo.org> > On Behalf Of oswall arguedas Sent: 12 July 2018 17:09 To: pharo-users@lists.pharo.org <mailto:pharo-users@lists.pharo.org> Subject: Re: [Pharo-users] XML support for pharo Regards, I practice with the example of the book. I can not read the atomic values of the nodes. For example, with this piece of the example: <cardset> <card> <cardname lang = "en"> Arcane Lighthouse </ cardname> <types> Land </ types> <year> 2014 </ year> To get the atomic value of the node year and assign it to the variable yearmem, I do it like this: yearmem: = tree xpath: '/ cardset / card / year'. But it fails. How do I get the 2014 value? Thank you Oswall _____ De: Pharo-users <pharo-users-bounces@lists.pharo.org <mailto:pharo-users-bounces@lists.pharo.org> > en nombre de oswall arguedas <oswallcr@hotmail.com <mailto:oswallcr@hotmail.com> > Enviado: miércoles, 11 de julio de 2018 20:17:55 Para: pharo-users@lists.pharo.org <mailto:pharo-users@lists.pharo.org> Asunto: Re: [Pharo-users] XML support for pharo Thanks Franz and Monty. I'm working on it, everything is going very well. The feedback when I master it. Oswall _____ De: Pharo-users <pharo-users-bounces@lists.pharo.org <mailto:pharo-users-bounces@lists.pharo.org> > en nombre de monty <monty2@programmer.net <mailto:monty2@programmer.net> > Enviado: miércoles, 11 de julio de 2018 03:32 Para: pharo-users@lists.pharo.org <mailto:pharo-users@lists.pharo.org> Asunto: Re: [Pharo-users] XML support for pharo This is the latest version of the XML/XPath Scraping Booklet: <https://files.pharo.org/books-pdfs/booklet-Scraping/2018-01-07-scrapingbook .pdf> <https://files.pharo.org/books-pdfs/booklet-Scraping/2018-01-07-scrapingbook .pdf> Scraping HTML with XPath - files.pharo.org files.pharo.org 1.6 Alargeexample  Siblings.Siblingsarechildnodesthathavethesameparent.Thecard-name,types,year, rarity,expansionandcardtextelementsareallsib- ___ montyos.wordpress.com
Solved To access the values of the nodes is as follows: yearmem: = (tree xpath: '// year') first contentString asNumber. I also edit the other methods of the XMLNode class. Thanks Oswall ________________________________ De: Pharo-users <pharo-users-bounces@lists.pharo.org> en nombre de PBKResearch <peter@pbkresearch.co.uk> Enviado: jueves, 12 de julio de 2018 12:09:20 Para: 'Any question about pharo is welcome' Asunto: Re: [Pharo-users] XML support for pharo Hi Oswall Well, you have located the correct node, which is some kind of XMLNode, so all you need is to access its content. If you browse the class and look at its âaccessingâ protocol, you see the method XMLNode>>#contentString, which will give you, in your test case, â2014â as a string. If you want to enter it in the database as a number, asNumber will do thatâ HTH Peter Kenny From: Pharo-users <pharo-users-bounces@lists.pharo.org> On Behalf Of oswall arguedas Sent: 12 July 2018 18:35 To: 'Any question about pharo is welcome' <pharo-users@lists.pharo.org> Subject: Re: [Pharo-users] XML support for pharo Hello Peter, Thanks for your help. The value I get is: <year> 2014 </ year> What I need is to extract the atomic value of the node, which is: 2014 To assign it to variables and create objects. I can not find how to obtain that punctual value 2014. The main purpose is to read many xml files and create smalltak objects with that data, then save them in DB and process the data. ________________________________ De: Pharo-users <pharo-users-bounces@lists.pharo.org<mailto:pharo-users-bounces@lists.pharo.org>> en nombre de PBKResearch <peter@pbkresearch.co.uk<mailto:peter@pbkresearch.co.uk>> Enviado: jueves, 12 de julio de 2018 11:17:41 Para: 'Any question about pharo is welcome' Asunto: Re: [Pharo-users] XML support for pharo Hi Oswall What sort of failure did you get? It helps with this sort of thing to execute the code in a playground and inspect the result. One thing you need to know is that the result of xpath is almost always some sort of XMLCollection, even when there is only one element. I would expect the result you want if you write yearmem := (tree xpath: âcardset/card/yearâ) first. Note that you should not need a slash at the start; xpath starts searching in the children of the top node. Also you do not need to give every step of the hierarchy; you can always skip levels provided the result specifies a unique route to the node you want. So in this case you can write: yearmem := (tree xpath: â//yearâ) first. Hope this helps Peter Kenny From: Pharo-users <pharo-users-bounces@lists.pharo.org<mailto:pharo-users-bounces@lists.pharo.org>> On Behalf Of oswall arguedas Sent: 12 July 2018 17:09 To: pharo-users@lists.pharo.org<mailto:pharo-users@lists.pharo.org> Subject: Re: [Pharo-users] XML support for pharo Regards, I practice with the example of the book. I can not read the atomic values of the nodes. For example, with this piece of the example: <cardset> <card> <cardname lang = "en"> Arcane Lighthouse </ cardname> <types> Land </ types> <year> 2014 </ year> To get the atomic value of the node year and assign it to the variable yearmem, I do it like this: yearmem: = tree xpath: '/ cardset / card / year'. But it fails. How do I get the 2014 value? Thank you Oswall ________________________________ De: Pharo-users <pharo-users-bounces@lists.pharo.org<mailto:pharo-users-bounces@lists.pharo.org>> en nombre de oswall arguedas <oswallcr@hotmail.com<mailto:oswallcr@hotmail.com>> Enviado: miércoles, 11 de julio de 2018 20:17:55 Para: pharo-users@lists.pharo.org<mailto:pharo-users@lists.pharo.org> Asunto: Re: [Pharo-users] XML support for pharo Thanks Franz and Monty. I'm working on it, everything is going very well. The feedback when I master it. Oswall ________________________________ De: Pharo-users <pharo-users-bounces@lists.pharo.org<mailto:pharo-users-bounces@lists.pharo.org>> en nombre de monty <monty2@programmer.net<mailto:monty2@programmer.net>> Enviado: miércoles, 11 de julio de 2018 03:32 Para: pharo-users@lists.pharo.org<mailto:pharo-users@lists.pharo.org> Asunto: Re: [Pharo-users] XML support for pharo This is the latest version of the XML/XPath Scraping Booklet: <https://files.pharo.org/books-pdfs/booklet-Scraping/2018-01-07-scrapingbook....> Scraping HTML with XPath - files.pharo.org<https://files.pharo.org/books-pdfs/booklet-Scraping/2018-01-07-scrapingbook....> files.pharo.org 1.6 Alargeexample ⢠Siblings.Siblingsarechildnodesthathavethesameparent.Thecard-name,types,year,rarity,expansionandcardtextelementsareallsib- ___ montyos.wordpress.com
Hi Oswall, for processing, take a look also at these three projects. They work on top of XML libraries, but provide some automation/simplification/inference. https://github.com/peteruhnak/xml-dom-visitor https://github.com/peteruhnak/xml-magritte-generator https://github.com/peteruhnak/xmi-analyzer Peter On Thu, Jul 12, 2018 at 10:00 PM, oswall arguedas <oswallcr@hotmail.com> wrote:
Solved
To access the values of the nodes is as follows:
yearmem: = (tree xpath: '// year') first contentString asNumber.
I also edit the other methods of the XMLNode class.
Thanks Oswall
------------------------------ *De:* Pharo-users <pharo-users-bounces@lists.pharo.org> en nombre de PBKResearch <peter@pbkresearch.co.uk> *Enviado:* jueves, 12 de julio de 2018 12:09:20
*Para:* 'Any question about pharo is welcome' *Asunto:* Re: [Pharo-users] XML support for pharo
Hi Oswall
Well, you have located the correct node, which is some kind of XMLNode, so all you need is to access its content. If you browse the class and look at its âaccessingâ protocol, you see the method XMLNode>>#contentString, which will give you, in your test case, â2014â as a string. If you want to enter it in the database as a number, asNumber will do thatâ
HTH
Peter Kenny
*From:* Pharo-users <pharo-users-bounces@lists.pharo.org> *On Behalf Of *oswall arguedas *Sent:* 12 July 2018 18:35 *To:* 'Any question about pharo is welcome' <pharo-users@lists.pharo.org> *Subject:* Re: [Pharo-users] XML support for pharo
Hello Peter,
Thanks for your help.
The value I get is:
<year> 2014 </ year>
What I need is to extract the atomic value of the node, which is:
2014
To assign it to variables and create objects. I can not find how to obtain that punctual value 2014.
The main purpose is to read many xml files and create smalltak objects with that data, then save them in DB and process the data. ------------------------------
*De:* Pharo-users <pharo-users-bounces@lists.pharo.org> en nombre de PBKResearch <peter@pbkresearch.co.uk> *Enviado:* jueves, 12 de julio de 2018 11:17:41 *Para:* 'Any question about pharo is welcome' *Asunto:* Re: [Pharo-users] XML support for pharo
Hi Oswall
What sort of failure did you get? It helps with this sort of thing to execute the code in a playground and inspect the result.
One thing you need to know is that the result of xpath is almost always some sort of XMLCollection, even when there is only one element. I would expect the result you want if you write yearmem := (tree xpath: âcardset/card/yearâ) first.
Note that you should not need a slash at the start; xpath starts searching in the children of the top node.
Also you do not need to give every step of the hierarchy; you can always skip levels provided the result specifies a unique route to the node you want. So in this case you can write:
yearmem := (tree xpath: â//yearâ) first.
Hope this helps
Peter Kenny
*From:* Pharo-users <pharo-users-bounces@lists.pharo.org> *On Behalf Of *oswall arguedas *Sent:* 12 July 2018 17:09 *To:* pharo-users@lists.pharo.org *Subject:* Re: [Pharo-users] XML support for pharo
Regards,
I practice with the example of the book. I can not read the atomic values of the nodes.
For example, with this piece of the example:
<cardset>
<card>
<cardname lang = "en"> Arcane Lighthouse </ cardname>
<types> Land </ types>
<year> 2014 </ year>
To get the atomic value of the node year and assign it to the variable yearmem, I do it like this:
yearmem: = tree xpath: '/ cardset / card / year'.
But it fails. How do I get the 2014 value?
Thank you
Oswall
------------------------------
*De:* Pharo-users <pharo-users-bounces@lists.pharo.org> en nombre de oswall arguedas <oswallcr@hotmail.com> *Enviado:* miércoles, 11 de julio de 2018 20:17:55 *Para:* pharo-users@lists.pharo.org *Asunto:* Re: [Pharo-users] XML support for pharo
Thanks Franz and Monty. I'm working on it, everything is going very well.
The feedback when I master it.
Oswall
------------------------------
*De:* Pharo-users <pharo-users-bounces@lists.pharo.org> en nombre de monty <monty2@programmer.net> *Enviado:* miércoles, 11 de julio de 2018 03:32 *Para:* pharo-users@lists.pharo.org *Asunto:* Re: [Pharo-users] XML support for pharo
This is the latest version of the XML/XPath Scraping Booklet: < https://files.pharo.org/books-pdfs/booklet-Scraping/ 2018-01-07-scrapingbook.pdf>
Scraping HTML with XPath - files.pharo.org <https://files.pharo.org/books-pdfs/booklet-Scraping/2018-01-07-scrapingbook....>
files.pharo.org
1.6 Alargeexample ⢠Siblings.Siblingsarechildnodesthathavet hesameparent.Thecard-name,types,year,rarity,expansionandcardtextelementsar eallsib-
___ montyos.wordpress.com
Peter Uhnák wrote
What does this one do? Here is something similar-sounding: https://github.com/magritte-metamodel/XML-Bindings ----- Cheers, Sean -- Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
On Sun, Jul 15, 2018 at 3:38 PM, Sean P. DeNigris <sean@clipperadams.com> wrote:
Peter Uhnák wrote
What does this one do? Here is something similar-sounding: https://github.com/magritte-metamodel/XML-Bindings
Did you read the README? I am not sure what you are asking. Peter
Peter Uhnák wrote
Did you read the README?
If I had read you're wonderful readme, I wouldn't have asked ;) All clear now. Thanks. ----- Cheers, Sean -- Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
Hello Peter I proceed to install them in the project. I will feed it back. Thanks Oswall ________________________________ De: Pharo-users <pharo-users-bounces@lists.pharo.org> en nombre de Peter Uhnák <i.uhnak@gmail.com> Enviado: sábado, 14 de julio de 2018 15:29 Para: Any question about pharo is welcome Asunto: Re: [Pharo-users] XML support for pharo Hi Oswall, for processing, take a look also at these three projects. They work on top of XML libraries, but provide some automation/simplification/inference. https://github.com/peteruhnak/xml-dom-visitor https://github.com/peteruhnak/xml-magritte-generator https://github.com/peteruhnak/xmi-analyzer Peter On Thu, Jul 12, 2018 at 10:00 PM, oswall arguedas <oswallcr@hotmail.com<mailto:oswallcr@hotmail.com>> wrote: Solved To access the values of the nodes is as follows: yearmem: = (tree xpath: '// year') first contentString asNumber. I also edit the other methods of the XMLNode class. Thanks Oswall ________________________________ De: Pharo-users <pharo-users-bounces@lists.pharo.org<mailto:pharo-users-bounces@lists.pharo.org>> en nombre de PBKResearch <peter@pbkresearch.co.uk<mailto:peter@pbkresearch.co.uk>> Enviado: jueves, 12 de julio de 2018 12:09:20 Para: 'Any question about pharo is welcome' Asunto: Re: [Pharo-users] XML support for pharo Hi Oswall Well, you have located the correct node, which is some kind of XMLNode, so all you need is to access its content. If you browse the class and look at its âaccessingâ protocol, you see the method XMLNode>>#contentString, which will give you, in your test case, â2014â as a string. If you want to enter it in the database as a number, asNumber will do thatâ HTH Peter Kenny From: Pharo-users <pharo-users-bounces@lists.pharo.org<mailto:pharo-users-bounces@lists.pharo.org>> On Behalf Of oswall arguedas Sent: 12 July 2018 18:35 To: 'Any question about pharo is welcome' <pharo-users@lists.pharo.org<mailto:pharo-users@lists.pharo.org>> Subject: Re: [Pharo-users] XML support for pharo Hello Peter, Thanks for your help. The value I get is: <year> 2014 </ year> What I need is to extract the atomic value of the node, which is: 2014 To assign it to variables and create objects. I can not find how to obtain that punctual value 2014. The main purpose is to read many xml files and create smalltak objects with that data, then save them in DB and process the data. ________________________________ De: Pharo-users <pharo-users-bounces@lists.pharo.org<mailto:pharo-users-bounces@lists.pharo.org>> en nombre de PBKResearch <peter@pbkresearch.co.uk<mailto:peter@pbkresearch.co.uk>> Enviado: jueves, 12 de julio de 2018 11:17:41 Para: 'Any question about pharo is welcome' Asunto: Re: [Pharo-users] XML support for pharo Hi Oswall What sort of failure did you get? It helps with this sort of thing to execute the code in a playground and inspect the result. One thing you need to know is that the result of xpath is almost always some sort of XMLCollection, even when there is only one element. I would expect the result you want if you write yearmem := (tree xpath: âcardset/card/yearâ) first. Note that you should not need a slash at the start; xpath starts searching in the children of the top node. Also you do not need to give every step of the hierarchy; you can always skip levels provided the result specifies a unique route to the node you want. So in this case you can write: yearmem := (tree xpath: â//yearâ) first. Hope this helps Peter Kenny From: Pharo-users <pharo-users-bounces@lists.pharo.org<mailto:pharo-users-bounces@lists.pharo.org>> On Behalf Of oswall arguedas Sent: 12 July 2018 17:09 To: pharo-users@lists.pharo.org<mailto:pharo-users@lists.pharo.org> Subject: Re: [Pharo-users] XML support for pharo Regards, I practice with the example of the book. I can not read the atomic values of the nodes. For example, with this piece of the example: <cardset> <card> <cardname lang = "en"> Arcane Lighthouse </ cardname> <types> Land </ types> <year> 2014 </ year> To get the atomic value of the node year and assign it to the variable yearmem, I do it like this: yearmem: = tree xpath: '/ cardset / card / year'. But it fails. How do I get the 2014 value? Thank you Oswall ________________________________ De: Pharo-users <pharo-users-bounces@lists.pharo.org<mailto:pharo-users-bounces@lists.pharo.org>> en nombre de oswall arguedas <oswallcr@hotmail.com<mailto:oswallcr@hotmail.com>> Enviado: miércoles, 11 de julio de 2018 20:17:55 Para: pharo-users@lists.pharo.org<mailto:pharo-users@lists.pharo.org> Asunto: Re: [Pharo-users] XML support for pharo Thanks Franz and Monty. I'm working on it, everything is going very well. The feedback when I master it. Oswall ________________________________ De: Pharo-users <pharo-users-bounces@lists.pharo.org<mailto:pharo-users-bounces@lists.pharo.org>> en nombre de monty <monty2@programmer.net<mailto:monty2@programmer.net>> Enviado: miércoles, 11 de julio de 2018 03:32 Para: pharo-users@lists.pharo.org<mailto:pharo-users@lists.pharo.org> Asunto: Re: [Pharo-users] XML support for pharo This is the latest version of the XML/XPath Scraping Booklet: <https://files.pharo.org/books-pdfs/booklet-Scraping/2018-01-07-scrapingbook....> Scraping HTML with XPath - files.pharo.org<https://files.pharo.org/books-pdfs/booklet-Scraping/2018-01-07-scrapingbook....> files.pharo.org<http://files.pharo.org> 1.6 Alargeexample ⢠Siblings.Siblingsarechildnodesthathavethesameparent.Thecard-name,types,year,rarity,expansionandcardtextelementsareallsib- ___ montyos.wordpress.com<http://montyos.wordpress.com>
participants (6)
-
Franz Josef Konrad -
monty -
oswall arguedas -
PBKResearch -
Peter Uhnák -
Sean P. DeNigris