Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/apache-kafka/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
I';我在使用靓汤寻找时遇到问题<;名称></名称>;在xml中_Xml_Beautifulsoup - Fatal编程技术网

I';我在使用靓汤寻找时遇到问题<;名称></名称>;在xml中

I';我在使用靓汤寻找时遇到问题<;名称></名称>;在xml中,xml,beautifulsoup,Xml,Beautifulsoup,我正在尝试使用beautifulsoup.name获取漂亮的汤返回文本。但它只是给了我一个漂亮的汤对象的[文档]。关于如何使用Beautiful Soup返回XML文件中的文本,有什么建议吗 import BeautifulSoup as bsoup f = open(file) soup = bsoup(f) f.close() f = soup.name This code will return [document] But I'm looking to for a functio

我正在尝试使用beautifulsoup.name获取漂亮的汤返回文本。但它只是给了我一个漂亮的汤对象的[文档]。关于如何使用Beautiful Soup返回XML文件中的文本,有什么建议吗

import BeautifulSoup as bsoup
f = open(file)
soup = bsoup(f)
f.close()

f = soup.name

This code will return [document]


But I'm looking to for a function in beautiful soup to return:

<name>car</name>
将美化组导入为b组
f=打开(文件)
汤=B组(f)
f、 关闭()
f=汤名
此代码将返回[文档]
但我希望在beautiful soup中有一个函数可以返回:
汽车
根据《美丽的汤》第4章

我明白了

你想要

import BeautifulSoup as bsoup
f = open(file)
soup = BeautifulSoup(f)
f.close()`
print(soup.find('name'))

用于打印
car
print(soup.find('name').name)
用于打印
car

添加了一些代码。我对编码有点陌生,所以我使用的一些术语可能含糊不清或笨拙。请随时要求更多的澄清。