Re: [BangPypers] Access xml file form python script

2010-11-02 Thread Shashidhar P
Hi Avinash,
There is simple python library for parsing the XML file, accessing data,
adding, editing.
It is LXML. You can refer its documentation at: http://codespeak.net/lxml/.

On Tue, Nov 2, 2010 at 11:26 AM, Dhananjay Nene dhananjay.n...@gmail.comwrote:

 On Sun, Oct 31, 2010 at 5:12 PM, Avinash TM avinas...@gmail.com wrote:

  Hi All,
 
  I have created a simple xml document i.e., preferences.xml as follows
 
  ?xml version=1.0?
  object
   object name=category value=cricket
property name=titleCricket/property
property name=subscribers
 element name=avinash/
  element name=prashant/
/property
   /object
  /object
 
 
  My favourite light weight tool for xml is minidom
 http://docs.python.org/library/xml.dom.minidom.html
 http://docs.python.org/library/xml.dom.minidom.html
 http://www.boddie.org.uk/python/XML_intro.html

 If you are needing simple xml parsing capabilities - it might just suffice
 your needs and is built into python.



  Now i want to access the above data from a python script.
  I gone through some websites. But not getting actual idea.
  Should i use any data structures ( Lists, Dictionary, Tuples) in my
 python
  script.
  Can anybody help me
 
  Thanks  Regards
  Avinash
  ___
  BangPypers mailing list
  BangPypers@python.org
  http://mail.python.org/mailman/listinfo/bangpypers
 



 --
 
 blog: http://blog.dhananjaynene.com
 twitter: http://twitter.com/dnene
 ___
 BangPypers mailing list
 BangPypers@python.org
 http://mail.python.org/mailman/listinfo/bangpypers




-- 
Regards,

Shashidhar N.Paragonda
shashidha...@gmail.com
+919449073835
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Access xml file form python script

2010-11-02 Thread Gopalakrishnan Subramani
lxml also can be used along with the elementtree. Personally I liked the
element tree APIs and elegance.

On Tue, Nov 2, 2010 at 1:47 PM, Shashidhar P shashidha...@gmail.com wrote:

 Hi Avinash,
 There is simple python library for parsing the XML file, accessing data,
 adding, editing.
 It is LXML. You can refer its documentation at: http://codespeak.net/lxml/
 .

 On Tue, Nov 2, 2010 at 11:26 AM, Dhananjay Nene dhananjay.n...@gmail.com
 wrote:

  On Sun, Oct 31, 2010 at 5:12 PM, Avinash TM avinas...@gmail.com wrote:
 
   Hi All,
  
   I have created a simple xml document i.e., preferences.xml as follows
  
   ?xml version=1.0?
   object
object name=category value=cricket
 property name=titleCricket/property
 property name=subscribers
  element name=avinash/
   element name=prashant/
 /property
/object
   /object
  
  
   My favourite light weight tool for xml is minidom
  http://docs.python.org/library/xml.dom.minidom.html
  http://docs.python.org/library/xml.dom.minidom.html
  http://www.boddie.org.uk/python/XML_intro.html
 
  If you are needing simple xml parsing capabilities - it might just
 suffice
  your needs and is built into python.
 
 
 
   Now i want to access the above data from a python script.
   I gone through some websites. But not getting actual idea.
   Should i use any data structures ( Lists, Dictionary, Tuples) in my
  python
   script.
   Can anybody help me
  
   Thanks  Regards
   Avinash
   ___
   BangPypers mailing list
   BangPypers@python.org
   http://mail.python.org/mailman/listinfo/bangpypers
  
 
 
 
  --
  
  blog: http://blog.dhananjaynene.com
  twitter: http://twitter.com/dnene
  ___
  BangPypers mailing list
  BangPypers@python.org
  http://mail.python.org/mailman/listinfo/bangpypers
 



 --
 Regards,

 Shashidhar N.Paragonda
 shashidha...@gmail.com
 +919449073835
 ___
 BangPypers mailing list
 BangPypers@python.org
 http://mail.python.org/mailman/listinfo/bangpypers

___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Access xml file form python script

2010-11-01 Thread Dhananjay Nene
On Sun, Oct 31, 2010 at 5:12 PM, Avinash TM avinas...@gmail.com wrote:

 Hi All,

 I have created a simple xml document i.e., preferences.xml as follows

 ?xml version=1.0?
 object
  object name=category value=cricket
   property name=titleCricket/property
   property name=subscribers
element name=avinash/
 element name=prashant/
   /property
  /object
 /object


 My favourite light weight tool for xml is minidom
http://docs.python.org/library/xml.dom.minidom.html
http://docs.python.org/library/xml.dom.minidom.html
http://www.boddie.org.uk/python/XML_intro.html

If you are needing simple xml parsing capabilities - it might just suffice
your needs and is built into python.



 Now i want to access the above data from a python script.
 I gone through some websites. But not getting actual idea.
 Should i use any data structures ( Lists, Dictionary, Tuples) in my python
 script.
 Can anybody help me

 Thanks  Regards
 Avinash
 ___
 BangPypers mailing list
 BangPypers@python.org
 http://mail.python.org/mailman/listinfo/bangpypers




-- 

blog: http://blog.dhananjaynene.com
twitter: http://twitter.com/dnene
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


[BangPypers] Access xml file form python script

2010-10-31 Thread Avinash TM
Hi All,

I have created a simple xml document i.e., preferences.xml as follows

?xml version=1.0?
object
  object name=category value=cricket
   property name=titleCricket/property
   property name=subscribers
element name=avinash/
element name=prashant/
   /property
  /object
/object



Now i want to access the above data from a python script.
I gone through some websites. But not getting actual idea.
Should i use any data structures ( Lists, Dictionary, Tuples) in my python
script.
Can anybody help me

Thanks  Regards
Avinash
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Access xml file form python script

2010-10-31 Thread Noufal Ibrahim
On Sun, Oct 31 2010, Avinash TM wrote:

 Hi All,

 I have created a simple xml document i.e., preferences.xml as follows

 ?xml version=1.0?
 object
   object name=category value=cricket
property name=titleCricket/property
property name=subscribers
 element name=avinash/
 element name=prashant/
/property
   /object
 /object

[...]

The elementree module can help you parse this. Docs available here
http://docs.python.org/library/xml.etree.elementtree.html

However, this looks like configuration options of some kind so you might
be better off using the .ini file format and ConfigParser module 
http://docs.python.org/library/configparser.html



-- 
~noufal
http://nibrahim.net.in
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Access xml file form python script

2010-10-31 Thread Sujit Ghosal
Hi Avinash,
Expat module can be used to fetch the elements out of the XML document.

Hope that helps.

- Sujit

On Sun, Oct 31, 2010 at 6:47 PM, Noufal Ibrahim nou...@gmail.com wrote:

 On Sun, Oct 31 2010, Avinash TM wrote:

  Hi All,
 
  I have created a simple xml document i.e., preferences.xml as follows
 
  ?xml version=1.0?
  object
object name=category value=cricket
 property name=titleCricket/property
 property name=subscribers
  element name=avinash/
  element name=prashant/
 /property
/object
  /object

 [...]

 The elementree module can help you parse this. Docs available here
 http://docs.python.org/library/xml.etree.elementtree.html

 However, this looks like configuration options of some kind so you might
 be better off using the .ini file format and ConfigParser module
 http://docs.python.org/library/configparser.html



 --
 ~noufal
 http://nibrahim.net.in
 ___
 BangPypers mailing list
 BangPypers@python.org
 http://mail.python.org/mailman/listinfo/bangpypers

___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Access xml file form python script

2010-10-31 Thread Pradeep Gowda
On Sun, Oct 31, 2010 at 7:42 AM, Avinash TM avinas...@gmail.com wrote:
 Hi All,

 I have created a simple xml document i.e., preferences.xml as follows

 ?xml version=1.0?
 object
  object name=category value=cricket
   property name=titleCricket/property
   property name=subscribers
    element name=avinash/
 element name=prashant/
   /property
  /object
 /object

This looks like xml generated by a Microsoft product, and not by/for a human..

How is this better than:

options
 category name=cricket title=Cricket
  subscribers
subscriber name=Avinash /
subsriber name=Prashanth /
  /subscribers
 /category
/options

Why create child nodes when attributes are sufficient?

+PG
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers