Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8328467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T01:27:15+00:00 2026-06-09T01:27:15+00:00

I’m trying to learn the basics of XML processing (with lxml) running Python 2.7.2.

  • 0

I’m trying to learn the basics of XML processing (with lxml) running Python 2.7.2. I’ve created a REALLY simple starting file, but it’s cratering. The code is:

from lxml import etree

doc = etree.parse('/Desktop/plc_dmt.xml')

print doc

I’ve tried variations on this code, using different xml files, and also opening the file first before executing the etree.parse() method, but they all yield a similar or identical error message, below:

Traceback (most recent call last):
  File "XMLparse_test.py", line 7, in <module>
    doc = etree.parse('/Users/Dad/Desktop/plc_dmt.xml')
  File "lxml.etree.pyx", line 2954, in lxml.etree.parse (src/lxml/lxml.etree.c:56220)
 ...   {Misc  error stuff}
 ... 
  lxml.etree.XMLSyntaxError: xmlParsePI : no target name, line 3, column 14

I confirmed that at least some of the XML files were well-formed, at least insofar as they ran correctly on a web server. I don’t understand the error message — What is the target name it is seeking?

Here’s the input xml file.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<response>
<heartbeat><?--#exec cmd_argument='printf( "0x%02X%02X", InReadUByte( 0 ), InReadUByte( 1 ))'-->    </heartbeat>

<dmt node="1">
    <address><?--#exec cmd_argument='printf( "0x%02X", InReadUByte( 20 ))'--></address>
    <status><?--#exec cmd_argument='printf( "0x%02X", InReadUByte( 21 ))'--></status>
    <realflow><?--#exec cmd_argument='printf( "%f", InReadFloat( 22 ))'--></realflow>
    <pressure><?--#exec cmd_argument='printf( "0x%02X%02X", InReadUByte( 26 ), InReadUByte( 27 ))'--></pressure>
    <temp><?--#exec cmd_argument='printf( "0x%02X%02X", InReadUByte( 28 ), InReadUByte( 29 ))'--></temp>
</dmt>
# Misc stuff pulled out to keep file shorter...
</response>

Much of the embedded code are Server Side Include commands for this web server, which is connected to some instrumentation. This file does operate correctly on the server.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T01:27:17+00:00Added an answer on June 9, 2026 at 1:27 am

    Your XML is invalid because you have < and > characters inside your elements. They have to be escaped.

    If they were actually supposed to be comments, this is what it should be:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <response>
    <heartbeat><!--#exec cmd_argument='printf( "0x%02X%02X", InReadUByte( 0 ), InReadUByte( 1 ))'-->    </heartbeat>
    
    <dmt node="1">
        <address><!--#exec cmd_argument='printf( "0x%02X", InReadUByte( 20 ))'--></address>
        <status><!--#exec cmd_argument='printf( "0x%02X", InReadUByte( 21 ))'--></status>
        <realflow><!--#exec cmd_argument='printf( "%f", InReadFloat( 22 ))'--></realflow>
        <pressure><!--#exec cmd_argument='printf( "0x%02X%02X", InReadUByte( 26 ), InReadUByte( 27 ))'--></pressure>
        <temp><!--#exec cmd_argument='printf( "0x%02X%02X", InReadUByte( 28 ), InReadUByte( 29 ))'--></temp>
    </dmt>
    </response>
    

    If that was actually supposed to be text, then they need to be escaped, like this:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <response>
    <heartbeat>&lt;?--#exec cmd_argument='printf( "0x%02X%02X", InReadUByte( 0 ), InReadUByte( 1 ))'--&gt;    </heartbeat>
    
    <dmt node="1">
        <address>&lt;?--#exec cmd_argument='printf( "0x%02X", InReadUByte( 20 ))'--&gt;</address>
        <status>&lt;?--#exec cmd_argument='printf( "0x%02X", InReadUByte( 21 ))'--&gt;</status>
        <realflow>&lt;?--#exec cmd_argument='printf( "%f", InReadFloat( 22 ))'--&gt;</realflow>
        <pressure>&lt;?--#exec cmd_argument='printf( "0x%02X%02X", InReadUByte( 26 ), InReadUByte( 27 ))'--&gt;</pressure>
        <temp>&lt;?--#exec cmd_argument='printf( "0x%02X%02X", InReadUByte( 28 ), InReadUByte( 29 ))'--&gt;</temp>
    </dmt>
    </response>
    

    The above two documents are both valid.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I am trying to render a haml file in a javascript response like so:
I have a French site that I want to parse, but am running into
In my XML file chapters tag has more chapter tag.i need to display chapters
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm parsing an XML file, the creators of it stuck in a bunch social
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.