从xml文件中提取值 [英] Extracting a value from an xml file

查看:110
本文介绍了从xml文件中提取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法使用python从xml文件中提取值?

Is there a way to use python to extract a value from an xml file?

推荐答案


有没有一种使用python从xml文件中提取值的方法?
Is there a way to use python to extract a value from an xml file?



在python中解析xml的方法有很多种。我建议调查一个名为的模块python库参考中的minidom 。他们有一个简单的示例来帮助您开始。

There are many different ways to parse xml in python. I would suggest looking into a module called minidom in the python library reference. They have a simple example to help you get started.


我可以使用下面的代码来解析文件,但是如何使用值提取标记的值,例如''name'',并返回该值外部程序?
I can use the code below to parse the file, but how can I extract a value of a tag such as ''name'' with a value and return that value to an external program?
展开 | 选择 < span class =codeDivider> | Wrap | 行号


这是xml文件的内容如下所示,我想取值''name''并将其返回给外部程序。

this is what the contents of the xml file looks like and I want to take the value of ''name'' and return that to an external program.

展开 | 选择 | Wrap | 行号


这篇关于从xml文件中提取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆