Python Forum
xml.etree.ElementTree extract string values
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
xml.etree.ElementTree extract string values
#3
Here one with BS as i never use ElementTree(has caused a lot of unnecessary problems for many people trough the years).
from bs4 import BeautifulSoup

soup = BeautifulSoup(open('comp.xml'), 'xml')
for row in soup.find_all('row_element'):
    print(row.text)
Output:
VALUE_STR_1 VALUE_STR_2 VALUE_STR_3 VALUE_STR_4 VALUE_STR_5 VALUE_STR_6 VALUE_STR_7 VALUE_STR_8 VALUE_STR_9 VALUE_STR_10
Reply


Messages In This Thread
RE: xml.etree.ElementTree extract string values - by snippsat - Jul-12-2020, 06:02 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  extract substring from a string before a word !! evilcode1 3 544 Nov-08-2023, 12:18 AM
Last Post: evilcode1
  Trying to compare string values in an if statement israelsattleen 1 554 Jul-08-2023, 03:49 PM
Last Post: deanhystad
  xml file editing with lxml.etree FlavioBueno 2 683 Jun-09-2023, 02:00 PM
Last Post: FlavioBueno
  Getting rid of old string values Pedroski55 3 1,020 Oct-11-2022, 10:56 PM
Last Post: Pedroski55
  mutable values to string items? fozz 15 2,817 Aug-30-2022, 07:20 PM
Last Post: deanhystad
  [SOLVED] [ElementTree] Grab text in attributes? Winfried 3 1,638 May-27-2022, 04:59 PM
Last Post: Winfried
  [ElementTree] Insert big block of HTML? Winfried 0 1,185 May-12-2022, 07:08 AM
Last Post: Winfried
  ElementTree get attribute value part of string paulo79 1 2,147 Apr-05-2022, 09:13 PM
Last Post: deanhystad
  PDF Extract using CSV values atomxkai 5 2,014 Jan-13-2022, 12:20 PM
Last Post: Pedroski55
  Extract a string between 2 words from a text file OscarBoots 2 1,879 Nov-02-2021, 08:50 AM
Last Post: ibreeden

Forum Jump:

User Panel Messages

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