【发布时间】:2022-07-19 00:13:56
【问题描述】:
**我正在尝试解析此 XML 链接,但每当我尝试使用 getroot() 函数获取 root 权限时,它都会显示“NoneType”对象不可调用。而且我还想知道如何遍历这个 XML 并打印入口标签内的所有字符串标签。 **
import pandas as pd
import urllib.request
from urllib.request import urlopen
import json
import xml.etree.ElementTree as ET
from bs4 import BeautifulSoup
import requests
url='https://www.omicsdi.org/ws/dataset/pride/PXD002885?debug=false' // this is the XML url you can refer to
print(url)
response =requests.get(url) //getting some output as: b'{"database":"Pride","file_versions":[{"files":{"Mgf":["ftp://ftp.pride.ebi.ac.uk/pride/da...........
soup = BeautifulSoup(response.content, 'lxml')
print(soup) //getting output as: <html><body><p>{"database":"Pride","file_versions":[{"files"................
myroot = soup.getroot() // getting error: 'NoneType' object is not callable
【问题讨论】: