Как распечатать только детей из результата поиска? - PullRequest
0 голосов
/ 30 октября 2018

Вот разметка xml

  <p:transition spd="slow">
    <p:push dir="u"/>
  </p:transition>

Вот мой код:

    namespaces = {
       'p': 'http://schemas.openxmlformats.org/presentationml/2006/main'
    }

    transitions = et.findall('p:transition', namespaces)
    if transitions:
        # Only worry about the first node for now
        for p in transitions[0].iter():
            print p.tag, p.text

Вывод на печать

{http://schemas.openxmlformats.org/presentationml/2006/main}transition

{http://schemas.openxmlformats.org/presentationml/2006/main}push None

Я бы хотел пропустить узел p:transition. Как я могу сказать, p:transition является родительским узлом p:push?

Кроме того, есть ли возможность убрать префикс расширенного пространства имен из распечатки тега: {http://schemas.openxmlformats.org/presentationml/2006/main} (или в этом случае p:push в порядке)

...