I
want to divide into parts a stream, a text. I explain: I have a xml file, desire that it be uploaded to stream (already done) but now I want to
divide into parts when the tag <product> appears AND save to variables or an array:
<product>
<a001>200702060470023090</a001>
<a002>03</a002>
<productidentifier>
<b221>02</b221>
<b244>0470023090</b244>
</productidentifier>
</product>
<product>
<othertext>
<d102>18</d102>
<d103>02</d103>
</othertext>
</product>
In this case two parts but the entire xml file has much more!
I tried: string[] producto = str.Split('<product>');
But error... :-(
Thanks in advanced!
<product>
<a001>200702060470023090</a001>
<a002>03</a002>
<productidentifier>
<b221>02</b221>
<b244>0470023090</b244>
</productidentifier>
</product>
<product>
<othertext>
<d102>18</d102>
<d103>02</d103>
</othertext>
</product>
In this case two parts but the entire xml file has much more!
I tried: string[] producto = str.Split('<product>');
But error... :-(
Thanks in advanced!
Diogo4 pointsPosted May 5, 2008, 7:38 AM EDT
while (!sr.EndOfStream)
{
str = sr.ReadLine();
Regex regex = new Regex("<product>");
products = regex.Split(str);
}
I founded this soluction!