XML support for pharo

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

XML support for pharo

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

Reply | Threaded
Open this post in threaded view
|

Re: XML support for pharo

Franz Josef Konrad-2
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.pdf>.

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=1294792&query=author%3A%22monty%22&days=600&i=24>
searches all entries of monty in the last 600 days.

HTH,
Franz Josef

Reply | Threaded
Open this post in threaded view
|

Re: XML support for pharo

monty-3
This is the latest version of the XML/XPath Scraping Booklet: <https://files.pharo.org/books-pdfs/booklet-Scraping/2018-01-07-scrapingbook.pdf>

___
montyos.wordpress.com

Reply | Threaded
Open this post in threaded view
|

Re: XML support for pharo

oswall arguedas

Thanks Franz and Monty. I'm working on it, everything is going very well.
The feedback when I master it.

Oswall


De: Pharo-users <[hidden email]> en nombre de monty <[hidden email]>
Enviado: miércoles, 11 de julio de 2018 03:32:35
Para: [hidden email]
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>

___
montyos.wordpress.com

Reply | Threaded
Open this post in threaded view
|

Re: XML support for pharo

oswall arguedas
In reply to this post by monty-3

Thanks Franz and Monty. I'm working on it, everything is going very well.
The feedback when I master it.

Oswall




De: Pharo-users <[hidden email]> en nombre de monty <[hidden email]>
Enviado: miércoles, 11 de julio de 2018 03:32
Para: [hidden email]
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>



___
montyos.wordpress.com

Reply | Threaded
Open this post in threaded view
|

Re: XML support for pharo

oswall arguedas

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 <[hidden email]> en nombre de oswall arguedas <[hidden email]>
Enviado: miércoles, 11 de julio de 2018 20:17:55
Para: [hidden email]
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 <[hidden email]> en nombre de monty <[hidden email]>
Enviado: miércoles, 11 de julio de 2018 03:32
Para: [hidden email]
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>
files.pharo.org
1.6 Alargeexample • Siblings.Siblingsarechildnodesthathavethesameparent.Thecard-name,types,year,rarity,expansionandcardtextelementsareallsib-



___
montyos.wordpress.com

Reply | Threaded
Open this post in threaded view
|

Re: XML support for pharo

Peter Kenny

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 <[hidden email]> On Behalf Of oswall arguedas
Sent: 12 July 2018 17:09
To: [hidden email]
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 <[hidden email]> en nombre de oswall arguedas <[hidden email]>
Enviado: miércoles, 11 de julio de 2018 20:17:55
Para: [hidden email]
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 <[hidden email]> en nombre de monty <[hidden email]>
Enviado: miércoles, 11 de julio de 2018 03:32
Para: [hidden email]
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>

files.pharo.org

1.6 Alargeexample • Siblings.Siblingsarechildnodesthathavethesameparent.Thecard-name,types,year,rarity,expansionandcardtextelementsareallsib-




___
montyos.wordpress.com

Reply | Threaded
Open this post in threaded view
|

Re: XML support for pharo

oswall arguedas
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 <[hidden email]> en nombre de PBKResearch <[hidden email]>
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 <[hidden email]> On Behalf Of oswall arguedas
Sent: 12 July 2018 17:09
To: [hidden email]
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 <[hidden email]> en nombre de oswall arguedas <[hidden email]>
Enviado: miércoles, 11 de julio de 2018 20:17:55
Para: [hidden email]
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 <[hidden email]> en nombre de monty <[hidden email]>
Enviado: miércoles, 11 de julio de 2018 03:32
Para: [hidden email]
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>

files.pharo.org

1.6 Alargeexample • Siblings.Siblingsarechildnodesthathavethesameparent.Thecard-name,types,year,rarity,expansionandcardtextelementsareallsib-




___
montyos.wordpress.com

Reply | Threaded
Open this post in threaded view
|

Re: XML support for pharo

Peter Kenny

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 <[hidden email]> On Behalf Of oswall arguedas
Sent: 12 July 2018 18:35
To: 'Any question about pharo is welcome' <[hidden email]>
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 <[hidden email]> en nombre de PBKResearch <[hidden email]>
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 <[hidden email]> On Behalf Of oswall arguedas
Sent: 12 July 2018 17:09
To: [hidden email]
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 <[hidden email]> en nombre de oswall arguedas <[hidden email]>
Enviado: miércoles, 11 de julio de 2018 20:17:55
Para: [hidden email]
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 <[hidden email]> en nombre de monty <[hidden email]>
Enviado: miércoles, 11 de julio de 2018 03:32
Para: [hidden email]
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>

files.pharo.org

1.6 Alargeexample • Siblings.Siblingsarechildnodesthathavethesameparent.Thecard-name,types,year,rarity,expansionandcardtextelementsareallsib-




___
montyos.wordpress.com

Reply | Threaded
Open this post in threaded view
|

Re: XML support for pharo

oswall arguedas

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 <[hidden email]> en nombre de PBKResearch <[hidden email]>
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 <[hidden email]> On Behalf Of oswall arguedas
Sent: 12 July 2018 18:35
To: 'Any question about pharo is welcome' <[hidden email]>
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 <[hidden email]> en nombre de PBKResearch <[hidden email]>
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 <[hidden email]> On Behalf Of oswall arguedas
Sent: 12 July 2018 17:09
To: [hidden email]
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 <[hidden email]> en nombre de oswall arguedas <[hidden email]>
Enviado: miércoles, 11 de julio de 2018 20:17:55
Para: [hidden email]
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 <[hidden email]> en nombre de monty <[hidden email]>
Enviado: miércoles, 11 de julio de 2018 03:32
Para: [hidden email]
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>

files.pharo.org

1.6 Alargeexample • Siblings.Siblingsarechildnodesthathavethesameparent.Thecard-name,types,year,rarity,expansionandcardtextelementsareallsib-




___
montyos.wordpress.com

Reply | Threaded
Open this post in threaded view
|

Re: XML support for pharo

Peter Uhnák
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.


Peter

On Thu, Jul 12, 2018 at 10:00 PM, oswall arguedas <[hidden email]> 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 <[hidden email]> en nombre de PBKResearch <[hidden email]>
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 <[hidden email]> On Behalf Of oswall arguedas
Sent: 12 July 2018 18:35
To: 'Any question about pharo is welcome' <[hidden email]>
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 <[hidden email]> en nombre de PBKResearch <[hidden email]>
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 <[hidden email]> On Behalf Of oswall arguedas
Sent: 12 July 2018 17:09
To: [hidden email]
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 <[hidden email]> en nombre de oswall arguedas <[hidden email]>
Enviado: miércoles, 11 de julio de 2018 20:17:55
Para: [hidden email]
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 <[hidden email]> en nombre de monty <[hidden email]>
Enviado: miércoles, 11 de julio de 2018 03:32
Para: [hidden email]
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.Siblingsarechildnodesthathavethesameparent.Thecard-name,types,year,rarity,expansionandcardtextelementsareallsib-




___
montyos.wordpress.com


Reply | Threaded
Open this post in threaded view
|

Re: XML support for pharo

Sean P. DeNigris
Administrator
Peter Uhnák wrote
> https://github.com/peteruhnak/xml-magritte-generator

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

Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: XML support for pharo

Peter Uhnák


On Sun, Jul 15, 2018 at 3:38 PM, Sean P. DeNigris <[hidden email]> wrote:
Peter Uhnák wrote
> https://github.com/peteruhnak/xml-magritte-generator

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
Reply | Threaded
Open this post in threaded view
|

Re: XML support for pharo

Sean P. DeNigris
Administrator
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

Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: XML support for pharo

oswall arguedas
In reply to this post by Peter Uhnák
Hello Peter

I proceed to install them in the project.

I will feed it back.

Thanks
Oswall

De: Pharo-users <[hidden email]> en nombre de Peter Uhnák <[hidden email]>
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.


Peter

On Thu, Jul 12, 2018 at 10:00 PM, oswall arguedas <[hidden email]> 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 <[hidden email]> en nombre de PBKResearch <[hidden email]>
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 <[hidden email]> On Behalf Of oswall arguedas
Sent: 12 July 2018 18:35
To: 'Any question about pharo is welcome' <[hidden email]>
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 <[hidden email]> en nombre de PBKResearch <[hidden email]>
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 <[hidden email]> On Behalf Of oswall arguedas
Sent: 12 July 2018 17:09
To: [hidden email]
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 <[hidden email]> en nombre de oswall arguedas <[hidden email]>
Enviado: miércoles, 11 de julio de 2018 20:17:55
Para: [hidden email]
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 <[hidden email]> en nombre de monty <[hidden email]>
Enviado: miércoles, 11 de julio de 2018 03:32
Para: [hidden email]
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.Siblingsarechildnodesthathavethesameparent.Thecard-name,types,year,rarity,expansionandcardtextelementsareallsib-




___
montyos.wordpress.com