minidom

I can't import xml.dom.minidom in PyCharm. What could I Try?

你离开我真会死。 提交于 2020-06-08 19:17:37
问题 I'm trying to import xml.dom.minidom but pycharm doesn't find it, altough it finds xml.entree / xml.parser / xml.sax. The rest of the standart libraries work all fine. The xml file (beispiel.xml) shouldn't be the problem, because it hasn't "xml" in the name. from xml.dom import minidom document = minidom.parse("beispiel.xml") wanted_info = input("Which prduct do you want to see?") product_list = document.getElementsByTagName(wanted_info) for product in product_list: for value in product

I can't import xml.dom.minidom in PyCharm. What could I Try?

♀尐吖头ヾ 提交于 2020-06-08 19:17:08
问题 I'm trying to import xml.dom.minidom but pycharm doesn't find it, altough it finds xml.entree / xml.parser / xml.sax. The rest of the standart libraries work all fine. The xml file (beispiel.xml) shouldn't be the problem, because it hasn't "xml" in the name. from xml.dom import minidom document = minidom.parse("beispiel.xml") wanted_info = input("Which prduct do you want to see?") product_list = document.getElementsByTagName(wanted_info) for product in product_list: for value in product

How to access the XML declaration with minidom (python) [duplicate]

孤者浪人 提交于 2020-01-07 07:20:13
问题 This question already has an answer here : Modify XML declaration with python (1 answer) Closed 4 years ago . In python, with minidom, is it possible to read/modify the XML declaration? I have a xml file which starts with <?xml version="1.0" encoding='UTF-8' standalone='yes' ?> and I'd like for e.g. to change it to <?xml-stylesheet href='form.xslt' type='text/xsl' ?> 回答1: You can have both <?xml ?> and <?xml-stylesheet ?> (they known as processing instructions , btw) in one XML. To add one,

Finding an xml node by its name rather than by its index

两盒软妹~` 提交于 2020-01-06 19:44:10
问题 How do I find an xml node by its name and get its value between the tags? I'm doing that the following way: from xml.dom import minidom dom = minidom.parseString(ET.tostring(ET.fromstring(some_xml), "utf-8")) self.a1 = dom.childNodes[0].childNodes[4].childNodes[0].nodeValue self.a2 = dom.childNodes[0].childNodes[5].childNodes[0].nodeValue I want to do that using the name of the tag instead of using its index in an array childNodes . How? update : <ReconnectResponse xmlns:xsd="http://www.w3

add element with attributes in minidom python

末鹿安然 提交于 2019-12-30 04:02:06
问题 I want to add a child node with attributes to a specific tag. my xml is <deploy> </deploy> and the output should be <deploy> <script name="xyz" action="stop"/> </deploy> so far my code is: dom = parse("deploy.xml") script = dom.createElement("script") dom.childNodes[0].appendChild(script) dom.writexml(open(weblogicDeployXML, 'w')) script.setAttribute("name", args.script) How can I figure out how to find deploy tag and append child node with attributes ? 回答1: xml.dom.Element.setAttribute

Python minidom: How to access an element

与世无争的帅哥 提交于 2019-12-25 07:10:03
问题 I'm working on parsing an XML-Sheet in Python. The XML has a structure like this: <layer1> <layer2> <element> <info1></info1> </element> <element> <info1></info1> </element> <element> <info1></info1> </element> </layer2> </layer1> Without layer2, I have no problems to acess the data in info1. But with layer2, I'm really in trouble. Their I can adress info1 with: root.firstChild.childNodes[0].childNodes[0].data So my thought was, that I can do it similiar like this: root.firstChild.firstChild

How could I infuse elements with other elements in an xml using Minidom?

佐手、 提交于 2019-12-25 06:27:00
问题 I'm using minidom with Python 3.5 The original xml data looks like this: (# of Beat and EditData_Score node/tags are fixed (in this case 3 each). <EditData_Score> <EditDataType>BEAT_SCORE</EditDataType> <Spot>20</Spot> <Time>7</Time> <Type>X</Type> <Beat> <EditDataType>BEAT_MARK</EditDataType> <Spot>26</Spot> <BeatLength>4.84472036</BeatLength> </Beat> </EditData_Score> <EditData_Score> <EditDataType>BEAT_SCORE</EditDataType> <Spot>36</Spot> <Time>10</Time> <Type>X</Type> <Beat> <EditDataType

lxml preserves attributes order?

自闭症网瘾萝莉.ら 提交于 2019-12-24 11:27:47
问题 I was writing my aplication using minidom but minidom does not preserve attribute order(sorts alphabetically), so I decided to do it using lxml. However in the following lines of code I'm not getting the desired order: import lxml.etree as ET SATNS = "link_1" NS = "link_2" location_attribute = '{%s}schemaLocation' % NS root = ET.Element('{%s}Catalogo' % SATNS, nsmap={'catalogocuentas':SATNS}, attrib= {location_attribute: 'http://www.sat.gob.mx/catalogocuentas'}, Ano="2014", Mes="02",

How to get inner content as string using minidom from xml.dom?

≯℡__Kan透↙ 提交于 2019-12-24 09:39:21
问题 I have some text tags in my xml file (pdf converted to xml using pdftohtml from popplers-utils) that looks like this: <text top="525" left="170" width="603" height="16" font="1">..part of old large book</text> <text top="546" left="128" width="645" height="16" font="1">with many many pages and some <i>italics text among 'plain' text</i> and more and more text</text> <text top="566" left="128" width="642" height="16" font="1">etc...</text> and I can get text envolved with text tag with this

Python Minidom : Change Value of Node

余生长醉 提交于 2019-12-23 20:39:47
问题 I'm using Python's minidom library to try and manipulate some XML files. Here is an example file : <document> <item> <link>http://www.this-is-a-url.com/</link> <description>This is some information!</description> </item> <item> <link>http://www.this-is-a-url.com/</link> <description>This is some information!</description> </item> <item> <link>http://www.this-is-a-url.com/</link> <description>This is some information!</description> </item> </document> What I need to do, is take the value in