Exemple #1
0
def dt_docxml_to_text(self, filename):

    texts = ""

    document = zipfile.ZipFile(filename)

    xml_content = document.read('word/document.xml')

    root = ET(xml_content)

    sections = []

    for section in root.getiterator(self.PARA):
        texts = ''
        for node in section.getiterator(self.TEXT):
            if node.text:
                texts += node.text

        sections.append(''.join(texts))

    texts = '\n\n'.join(sections)

    document.close()

    return texts
Exemple #2
0
def create_node(tag, property_map, content):
    '''新造一个节点
       tag:节点标签
       property_map:属性及属性值map
       content: 节点闭合标签里的文本内容
       return 新节点'''
    element = ET(tag, property_map)
    element.text = content
    return element
Exemple #3
0
def csc_to_graph(name):
    tree = ET(name)
    mote_id = [
        int(t.text) for t in tree.findall(".//mote/interface_config/id")
    ]
    mote_type = [t.text for t in tree.findall(".//mote/motetype_identifier")]
    x = [float(t.text) for t in tree.findall(".//mote/interface_config/x")]
    y = [float(t.text) for t in tree.findall(".//mote/interface_config/y")]
    z = [float(t.text) for t in tree.findall(".//mote/interface_config/z")]
Exemple #4
0
 def fromstring(cls, string):
     root = ET.fromstring(string)
     tree = ET(element=root)
     return cls(tree)
Exemple #5
0
def input_information():
    for node in note.getiterator('student'):
        node = Element("name")
        node.text = input("이름을 입력하세요(종료는 'Enter' 입력): ")
        node.append(node)
        ET().write('students_info2.xml')
Exemple #6
0
import xmltodict, json
import requests
import xml.etree.ElementTree as ET

url = "http://www.colourlovers.com/api/palettes/top"
r = requests.get(url)
root = ET(r.content)
print("results: ", root.attrib["numResults"])
for palette in root.iter("palette"):
    pass

# o = xmltodict.parse('<e> <a>text</a> <a>text</a> </e>')

# with open('jsonfiles/palettes/top.json', 'w') as outfile:
#     json.dump(r.content,outfile)