H.Choi
H.Choi

Reputation: 3223

how can i know how many same tags are in xml using beautifulsoup?

i have a xml like this:

<dd class='date'>
0705
</dd>
<dd class='date'>
0707
</dd>
<dd class='date'>
0710
</dd>
<dd class='date'>
0714
</dd>

the output i want is(i'm finding # of ):

4

is there a neat way to do this job? any help would be great. thanks in advance

Upvotes: 0

Views: 57

Answers (1)

Froyo
Froyo

Reputation: 18477

soup = BeautifulSoup("xml/html content")
tags = soup.find("some_tag")
print len(tags)

len(tags) will give you total number of tags.

Upvotes: 1

Related Questions