Hi I Have an XML file in which a row looks something like this,Which is getting interpreted by XML input stage.
<ColumnL>
<Schedule>
<Period>
<Date1>2009.06.24</Date1>
<Date2>2011.06.24</Date2>
</Period>
<Period>
<Date1>2010.06.24</Date1>
<Date2>2012.06.24</Date2>
</Period>
<Period>
<Date1>2011.06.24</Date1>
<Date2>2013.06.24</Date2>
</Period>
<Period>
<Date1>2012.06.25</Date1>
<Date2>2013.06.24</Date2>
</Period>
</Schedule>
</ColumnL>
There are many rows of the type ColumnL.
What my requirement is,to print the Date1 and Date2 text elements of Each Period different ColumnL rows,in a saperate row.So I have taken Period as a repetition element and taken an Xpath expression for the columns as
/ColumnL/Schedule/Date1/text()
/ColumnL/Schedule/Date2/text().
But for each ColumnL in the XML document, the Dates corresponding to first instance of Period is getting repeated.
ie,I am getting the output as
Date1 Date2
2009.06.24 2012.06.24
2009.06.24 2012.06.24
2009.06.24 2012.06.24
where as My required output is
Date1 Date2
2009.06.24 2012.06.24
2011.06.24 2013.06.24
2012.06.25 2013.06.24
I cannot use the indexed Xpath expressions here because I The number of Period elements can vary in each row of ColumnL.
Please suggest me a way to get this problem resolved...[/b]
Problem With parsing the XML file.
Moderators: chulett, rschirm, roy
-
- Charter Member
- Posts: 299
- Joined: Wed Nov 13, 2002 5:38 pm
- Location: USA
I'm confused here.... to be safe and keeping it clean, especially with the behavior of nulls and repeating elements, one of your date fields ought to be the repeating element, unless you are only going to go as deep as Period in your retrieval (and then play games later with the entire Period element).
/ColumnL/Schedule/Period/Date1/text()
/ColumnL/Schedule/Period/Date2/text()
with either of these as the repetition element. Then you'll get 4 rows from your top example, each with two columns, Date1 and Date2, paired as they are in the xml structure.
From that, please outline what result you "want" to have....
Ernie
/ColumnL/Schedule/Period/Date1/text()
/ColumnL/Schedule/Period/Date2/text()
with either of these as the repetition element. Then you'll get 4 rows from your top example, each with two columns, Date1 and Date2, paired as they are in the xml structure.
From that, please outline what result you "want" to have....
Ernie
Ernie Ostic
blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
I'm confused here.... to be safe and keeping it clean, especially with the behavior of nulls and repeating elements, one of your date fields ought to be the repeating element, unless you are only going to go as deep as Period in your retrieval (and then play games later with the entire Period element).
/ColumnL/Schedule/Period/Date1/text()
/ColumnL/Schedule/Period/Date2/text()
with either of these as the repetition element. Then you'll get 4 rows from your top example, each with two columns, Date1 and Date2, paired as they are in the xml structure.
From that, please outline what result you "want" to have....
Ernie
/ColumnL/Schedule/Period/Date1/text()
/ColumnL/Schedule/Period/Date2/text()
with either of these as the repetition element. Then you'll get 4 rows from your top example, each with two columns, Date1 and Date2, paired as they are in the xml structure.
From that, please outline what result you "want" to have....
Ernie
Ernie Ostic
blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
eostic wrote:I'm confused here.... to be safe and keeping it clean, especially with the behavior of nulls and repeating elements, one of your date fields ought to be the repeating element, unless you are only going to go as deep as Period in your retrieval (and then play games later with the entire Period element).
/ColumnL/Schedule/Period/Date1/text()
/ColumnL/Schedule/Period/Date2/text()
with either of these as the repetition element. Then you'll get 4 rows from your top example, each with two columns, Date1 and Date2, paired as they are in the xml structure.
From that, please outline what result you "want" to have....
Ernie
Thanks Ernie..It helped me in solving my problem
sun
Glad to hear. Have fun digging deeper into it. The Repetition Element gets especially interesting as you move forward with more complex examples, especially when one of your Date elements (in the example above) happens to not be in the current node......
Ernie
Ernie
Ernie Ostic
blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>