Jump to content

convert xml


Guest Ann

Recommended Posts

Hi I wanna convert xml file like <html> <body> <h1>Chapter 1</h1> <p>Then with expanded wings he steers his flight</p> <p>Aloft, incumbent on the dusky Air</p> <h2>Chapter 1, Section 1</h2> <p>That felt unusual weight, till on dry Land</p> <p>He lights, if it were Land that ever burned</p> </body></html> to a new xml format file <chapter> <section> <title>Chapter 1</title> <para>Then with expanded wings he steers his flight</para> <para author="ar">Aloft, incumbent on the dusky Air</para> </section> <section><title>Chapter 1, Section 1</title> <para>That felt unusual weight, till on dry Land</para> <para>He lights, if it were Land that ever burned</para> </section></chapter> I have tried several ways, but all failed. Does anyone could help me, or give me some suggestion. Thanks.

Link to comment
Share on other sites

Well, you don't have anything complicated, so the easiest thing to do is simple mapping:

<xsl:template match="oldElementName"><newElementName><xsl:apply-templates/></newElementName></xsl:template>

However, I don't understand how would you know the author of the second para? I mean it isn't written anywhere in the input.

Link to comment
Share on other sites

  • 4 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...