Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Need help!!!! Problem doing this bit of code
Forum Update on Monday, May 27th 2025

Need help!!!! Problem doing this bit of code

Scheduled Pinned Locked Moved Unsolved Qt for Python
3 Posts 3 Posters 262 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    darealmash
    wrote on 17 Mar 2022, 15:46 last edited by
    #1

    import xml.etree.ElementTree as ET

    data = ('''
    <person>
    <name>Chuck</name>
    <phone type = "intl">
    +1 734 303 4456
    </phone>
    <email hide+"yes"/>
    </person>''')

    tree = ET.fromstring(data)
    print('Name:', tree.find('name').text)
    print('Attr:', tree.find('email').get('hide'))

    i keep on getting this traceback: line 12, in <module>
    tree = ET.fromstring(data)
    and also get tracebac for the xml file elementtree:
    File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2800.0_x64__qbz5n2kfra8p0\lib\xml\etree\ElementTree.py", line 1347, in XML
    parser.feed(text)
    xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 7, column 21

    J 1 Reply Last reply 17 Mar 2022, 19:18
    0
    • J Offline
      J Offline
      JoeCFD
      wrote on 17 Mar 2022, 16:13 last edited by
      #2

      @darealmash said in Need help!!!! Problem doing this bit of code:

      <email hide+"yes"/>

      <email hide="yes"/>

      1 Reply Last reply
      2
      • D darealmash
        17 Mar 2022, 15:46

        import xml.etree.ElementTree as ET

        data = ('''
        <person>
        <name>Chuck</name>
        <phone type = "intl">
        +1 734 303 4456
        </phone>
        <email hide+"yes"/>
        </person>''')

        tree = ET.fromstring(data)
        print('Name:', tree.find('name').text)
        print('Attr:', tree.find('email').get('hide'))

        i keep on getting this traceback: line 12, in <module>
        tree = ET.fromstring(data)
        and also get tracebac for the xml file elementtree:
        File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2800.0_x64__qbz5n2kfra8p0\lib\xml\etree\ElementTree.py", line 1347, in XML
        parser.feed(text)
        xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 7, column 21

        J Offline
        J Offline
        JonB
        wrote on 17 Mar 2022, 19:18 last edited by
        #3

        @darealmash said in Need help!!!! Problem doing this bit of code:

        xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 7, column 21

        As @JoeCFD has said, did you try looking at line 7, column 21?

        1 Reply Last reply
        0

        1/3

        17 Mar 2022, 15:46

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved