1xmlData = None
2
3with open('conf//test1.xml', 'r') as xmlFile:
4 xmlData = xmlFile.read()
5
6xmlDecoded = xmlData
7
8xmlSoup = BeautifulSoup(xmlData, 'html.parser')
9
10repElemList = xmlSoup.find_all('repeatingelement')
11
12for repElem in repElemList:
13 print("Processing repElem...")
14 repElemID = repElem.get('id')
15 repElemName = repElem.get('name')
16
17 print("Attribute id = %s" % repElemID)
18 print("Attribute name = %s" % repElemName)
19
20
21
22# ==================================
23
24>>> from bs4 import BeautifulSoup
25>>> soup = BeautifulSoup('<META NAME="City" content="Austin">')
26>>> soup.find("meta", {"name":"City"})
27<meta name="City" content="Austin" />
28>>> soup.find("meta", {"name":"City"})['content']
29u'Austin'
30
1xmlData = None
2
3with open('conf//test1.xml', 'r') as xmlFile:
4 xmlData = xmlFile.read()
5
6xmlDecoded = xmlData
7
8xmlSoup = BeautifulSoup(xmlData, 'html.parser')
9
10repElemList = xmlSoup.find_all('repeatingelement')
11
12for repElem in repElemList:
13 print("Processing repElem...")
14 repElemID = repElem.get('id')
15 repElemName = repElem.get('name')
16
17 print("Attribute id = %s" % repElemID)
18 print("Attribute name = %s" % repElemName)