Apr-25-2017, 03:54 AM
Apr-25-2017, 05:27 PM
I tried this and get error that it can't find tmp/test.xml file:
Thanks snippsat - works fine.
from bs4 import BeautifulSoup open('/tmp/test.xml', 'r') xml_data = xml_file.read() soup = BeautifulSoup(xml_data, 'lxml') print(soup.gps.latitude.text)
Thanks snippsat - works fine.
Apr-25-2017, 06:01 PM
(Apr-25-2017, 05:27 PM)kendias Wrote: [ -> ]I tried this and get error that it can't find tmp/test.xml file:Is
test.xml
in tmp
folder?You have not copy code right from wavic post post.
with open('/tmp/test.xml', 'r') as xml_file: xml_data = xml_file.read() soup = BeautifulSoup(xml_data, 'lxml') print(soup.gps.latitude.text)Here you also need to install lxml
pip install lxml
Apr-25-2017, 08:03 PM
Thanks, initially copied verbatim from Wavic did not work hence changed it.
Not clear on test.xml i.e. where can I find it or is it a file I create myself?
Also link to d'load & install lxml.
Not clear on test.xml i.e. where can I find it or is it a file I create myself?
Also link to d'load & install lxml.
Apr-25-2017, 09:20 PM
(Apr-25-2017, 08:03 PM)kendias Wrote: [ -> ]Not clear on test.xml i.e. where can I find it or is it a file I create myself?You most of course make the file or point to the file with your XML data.
Quote:Also link to d'load & install lxmllxml
pip
is Python install tool,it dos all automatic download and install.Check in Terminal or cmd(Windows) that is work.
Eg:
$ pip -V pip 9.0.1 from /home/mint/new_age/lib/python3.5/site-packages (python 3.5)
Apr-25-2017, 10:42 PM
Tried pip -V, then pip 9.0.1 from /home/mint/new_age/lib/python3.5/site-packages (python 3.5); get error msg on 9.0.1, just will not take it.
Entered these commands in the cmdline
Entered these commands in the cmdline
Apr-25-2017, 10:59 PM
It's just
pip -V
enter,it will return something else for you if it work.Apr-25-2017, 11:34 PM
Thanks. Did pip -V and got "pip 1.5.6 from /usr/lib/python2.7/dist-packages (python 2.7)". From what you said this is OK. Now what about lxml - has to be installed?
Apr-26-2017, 12:15 AM
Hello!
You should look at the code, not just blindly copy/paste it.
'tmp/test.xml' is 'test.xml' file which I created from the xml snippet that you have provided. And its location is in the tmp/ directory. But this is on my computer. The path and the file name on yours could be different.
As @snippsat already noticed
You should look at the code, not just blindly copy/paste it.

'tmp/test.xml' is 'test.xml' file which I created from the xml snippet that you have provided. And its location is in the tmp/ directory. But this is on my computer. The path and the file name on yours could be different.
(Apr-25-2017, 11:34 PM)kendias Wrote: [ -> ]Now what about lxml - has to be installed?Yes. The command to do it is: pip install lxml
As @snippsat already noticed
Apr-26-2017, 01:02 AM
Thanks! Works fine now.