0
<XMLReport><Report>
<Preflight errors="0" criticalfailures="0" noncriticalfailures="0" signoffs="0" fixes="0" warnings="10">
  <PreflightResult type="Check" level="warning">
    <PreflightResultEntry xml:lang="en-US">
      <Message>PDF/X-1a:20000 : PDF/X-1a:20000 output intent is missing </Message>
      <StringContext>
        <BaseString>PDF/X-1a:20000 : %PDFXVersion% output intent is missing</BaseString>
      </StringContext>
    </PreflightResultEntry>
  </PreflightResult>
</Preflight></Report>

I want to get all value/text in <Message> </Message> element using lxml in Python.

Thanks

2
  • 2
    What have you tried? Commented Jun 27, 2012 at 7:14
  • Question title should have your question and not what you have. Commented Jun 27, 2012 at 7:16

1 Answer 1

2

Easy from the lxml tuto:

>>> from lxml import etree
>>> s = """<Report>
<Preflight errors="0" criticalfailures="0" noncriticalfailures="0" signoffs="0" fixes="0" warnings="10">
  <PreflightResult type="Check" level="warning">
    <PreflightResultEntry xml:lang="en-US">
      <Message>PDF/X-1a:20000 : PDF/X-1a:20000 output intent is missing </Message>
      <StringContext>
        <BaseString>PDF/X-1a:20000 : %PDFXVersion% output intent is missing</BaseString>
      </StringContext>
    </PreflightResultEntry>
  </PreflightResult>
</Preflight></Report>
"""
>>> root = etree.XML(s)
>>> for message in root.findall('Preflight/PreflightResult/PreflightResultEntry/Message'):
    print message.text


PDF/X-1a:20000 : PDF/X-1a:20000 output intent is missing 
>>> 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.