Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Parse XML with Namespaces
#6
The difference is that the built-in module only lets you use a subset of XPath, making certain things more complicated, or impossible.
For example, to get the ConnectionString attribute in lxml, you can simply do this:
>>> root.xpath('XYZ:ConnectionManagers/XYZ:ConnectionManager/XYZ:ObjectData/XYZ:ConnectionManager/@XYZ:ConnectionString', namespaces=ns)
['Data Source=RTG093939BB;Initial Catalog=AdminDB;Provider=SQLNCLI11.1;Integrated Security=SSPI;Auto Translate=False;', 'Data Source=RTG093955XT;Initial Catalog=Stage;Provider=SQLNCLI11.1;Integrated Security=SSPI;Auto Translate=False;']
Reply


Messages In This Thread
Parse XML with Namespaces - by dwill - Apr-11-2018, 09:51 PM
RE: Parse XML with Namespaces - by Larz60+ - Apr-12-2018, 01:13 AM
RE: Parse XML with Namespaces - by dwill - Apr-12-2018, 03:25 AM
RE: Parse XML with Namespaces - by stranac - Apr-12-2018, 07:58 AM
RE: Parse XML with Namespaces - by dwill - Apr-12-2018, 04:10 PM
RE: Parse XML with Namespaces - by stranac - Apr-12-2018, 06:51 PM
RE: Parse XML with Namespaces - by dwill - Apr-12-2018, 08:08 PM
RE: Parse XML with Namespaces - by dwill - Apr-12-2018, 09:22 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Still not completely clear about namespaces... bytecrunch 3 2,033 Oct-07-2022, 05:44 PM
Last Post: bytecrunch
  Modules and namespaces (again?) ptrivino 1 1,906 Oct-24-2020, 10:37 PM
Last Post: Larz60+
  namespaces in comprehension in exec() Skaperen 4 4,833 Mar-28-2017, 03:31 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020