[Python] How to add a namespace to an attribute in lxml

Discussão em 'Python' iniciado por Stack, Junho 6, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to create an xml entry that looks like this using python and lxml:

    <resource href="Unit 4.html" adlcp:scormtype="sco">


    I'm using python and lxml. I'm having trouble with the adlcp:scormtype attribute. I'm new to xml so please correct me if I'm wrong. adlcp is a namespace and scormtype is an attribute that is defined in the adlcp namespace, right?
    I'm not even sure if this is the right question but... My question is, how do I add an attribute to an element from a non-default namespace using lxml? I apologize in advance if this is a trivial question.

    Continue reading...

Compartilhe esta Página