-2

I have two XML files:

The first one contains the following tags:

<book id=1>
<chpater id=1>
<sentence id = 1>
blaa blaa blaa blaa 
</sentence>
<sentence id = 2>
blaa blaa blaa blaa blaa blaa blaa blaa 
</sentence>
</chapter>
<chpater id=2>
<sentence id = 1>
blaa blaa blaa blaa 
</sentence>
</chapter>
</book>
<book id =2>
<chapter id=1>
<sentence id=1>
blaa blaa blaa
</sentece>
</chpater>
</book>

The second file is a multivalued tag of the chapter tag as the following:

<book id=1>
<chapter id=1, name= introduction, length=short>

<book id=1>
<chapter id=2, name= animals, length=long>

for each book and chapter in that book a new tag has been made. How to replace the tag in the first file with the multi value tag . Remember the chapter id is not unique. but the book id is unique.

1 Answer 1

-1

take a look at lxml http://lxml.de/index.html It's a great librarie that features everything you need to accomplish this.

You'll have to parse both files and then use xpath to search for the right content in one file and copy it into the right element in the other file.

I'm not going to code the whole thing for you but if you have trouble with specific steps in your code, we'll be happy to help :)

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.