XML : In Python how to merge common tags in same xml

In Python how to merge common tags of same xml.

      <book>          <chapter id="113">          <word id="128160">              <POS Tag="P"/>              <grammar type="STEM"/>              <Aspect type="IMPV"/>              <Number type="S"/>          </word>          <word id="128161">              <POS Tag="V"/>              <grammar type="STEM"/>              <Aspect type="IMPF"/>          </word>          <word id="128160">              <TOS Tag="T"/>              <Tag Tag="bi+"/>          </word>          </chapter>      </book>    

can we convert to following :

      <book>          <chapter id="113">          <word id="128160">              <POS Tag="P"/>              <grammar type="STEM"/>              <Aspect type="IMPV"/>              <Number type="S"/>              <TOS Tag="T"/>              <Tag Tag="bi+"/>          </word>          <word id="128161">              <POS Tag="V"/>              <grammar type="STEM"/>              <Aspect type="IMPF"/>          </word>          </chapter>      </book>    

It would be helpful if single line command is available. Any help will be appreciated.

No comments:

Post a Comment