L
Luke Olek
Hello! I've posted few days before a message:
How to transform:
<html>
<h1>title</h1>
<h2>header1</h2>
Content
<h3>subeader1</h3>
Subcontent
</html>
to:
<newsletter>
<title>title</title>
<section header="header1">
Content
<subsection header="subheader1">
Subcontent
</subsection>
</section>
</newsletter>
I've received an answer, but I think it isn't what I meant.
Details:
Note, that first file:
<html>
<h1>title</h1>
<h2>header1</h2>
Content
<h3>subeader1</h3>
Subcontent
<h3>subeader2</h3>
Subcontent
<h2>header2</h2>
Content
<h3>subeader3</h3>
Subcontent
<h3>subeader4</h3>
Subcontent
</html>
is a flat file. Every node is on the same level: children of html
node.
What I need is to divide this into deeper structure:
<newsletter>
<title>title</title>
<section header="header1">
Content
<subsection header="subheader1">
Subcontent
</subsection>
<subsection header="subheader2">
Subcontent
</subsection>
</section>
<section header="header1">
Content
<subsection header="subheader1">
Subcontent
</subsection>
<subsection header="subheader2">
Subcontent
</subsection>
</section>
</newsletter>
I don't know is it possible or how to select each node between </h2>
of the current node and <h2> of the next section header.
<html>
<h1>title</h1>
<h2>header1</h2>
---->Content // This becomes the CHILDREN of <section>
created
----><h3>subeader1</h3> // from <h2> above.
---->Subcontent // How to select this as XPath Query?
----><h3>subeader2</h3> // The same will be done with <h3> tags,
but
---->Subcontent // they become <subsection> nodes
<h2>header2</h2>
Content
<h3>subeader3</h3>
Subcontent
<h3>subeader4</h3>
Subcontent
</html>
Any help appreciated!
How to transform:
<html>
<h1>title</h1>
<h2>header1</h2>
Content
<h3>subeader1</h3>
Subcontent
</html>
to:
<newsletter>
<title>title</title>
<section header="header1">
Content
<subsection header="subheader1">
Subcontent
</subsection>
</section>
</newsletter>
I've received an answer, but I think it isn't what I meant.
Details:
Note, that first file:
<html>
<h1>title</h1>
<h2>header1</h2>
Content
<h3>subeader1</h3>
Subcontent
<h3>subeader2</h3>
Subcontent
<h2>header2</h2>
Content
<h3>subeader3</h3>
Subcontent
<h3>subeader4</h3>
Subcontent
</html>
is a flat file. Every node is on the same level: children of html
node.
What I need is to divide this into deeper structure:
<newsletter>
<title>title</title>
<section header="header1">
Content
<subsection header="subheader1">
Subcontent
</subsection>
<subsection header="subheader2">
Subcontent
</subsection>
</section>
<section header="header1">
Content
<subsection header="subheader1">
Subcontent
</subsection>
<subsection header="subheader2">
Subcontent
</subsection>
</section>
</newsletter>
I don't know is it possible or how to select each node between </h2>
of the current node and <h2> of the next section header.
<html>
<h1>title</h1>
<h2>header1</h2>
---->Content // This becomes the CHILDREN of <section>
created
----><h3>subeader1</h3> // from <h2> above.
---->Subcontent // How to select this as XPath Query?
----><h3>subeader2</h3> // The same will be done with <h3> tags,
but
---->Subcontent // they become <subsection> nodes
<h2>header2</h2>
Content
<h3>subeader3</h3>
Subcontent
<h3>subeader4</h3>
Subcontent
</html>
Any help appreciated!