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.
ThanksOswall
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
1.6 Alargeexample ��� Siblings.
Siblingsarechildnodesthathavet hesameparent.Thecard-name, types,year,rarity, expansionandcardtextelementsar eallsib-