How to retrieve the contents of the name tag in XML with BeautifulSoup

Asked 2 years ago, Updated 2 years ago, 67 views

I am using BeautifulSoup4, Python 3.6.
The parser is lxml-xml.
Attempting to parse the following XML and get entry.name.string results in an error:
<entry><name>Foo>/name>>80>/value></entry>
It seems that the tag name used by BeautifulSoup is attached to the "name" attribute.
Is there any other way to retrieve child elements?

python python3 xml beautifulsoup

2022-09-29 20:25

1 Answers

In such cases, using the entry.find("name").string and the find function will work.


2022-09-29 20:25

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.