var result = (from item in doc.Descendants("OperatorId")
select item.Value).ToList();
foreach (var item in result)
{
var fresult = from items in doc.Descendants("CircleId")
where item.Trim().Equals("OperatorId")
select items;
foreach (var sitem in fresult)
{
//Do with Sqlcommand to save
}
}
and item does not have any property like item.Value
var result = (from item in doc.Descendants("OperatorId")
select item.Value).ToList();
foreach (var item in result)
{
var fresult = from citem in doc.Descendants("CircleId")
where citem.Value.Trim().Equals(item) select items;
foreach (var sitem in fresult)
{
//Do with Sqlcommand to save
}
}
XDocumentdoc=XDocument.Load("http://mobile.onestoprecharge.net/reseller/ResellerFlexiVouchersAPI.php?reseller_id=741&reseller_pass=123456");
//Fetch all OperatorIdvarids=doc.Descendants("OperatorId");
//Fetch all the CircleId below thatforeach (XElementiteminids)
{
//Get its parentvarparentNode=item.Parent;
//Fetch all the CircleIdvarresult=fromsiteminparentNode.Descendants("CircleId")
wheresitem.Value.Trim() ==item.Value.Trim()
selectsitem.Value;
//OutputConsole.WriteLine("ParentNodeName:"+parentNode.Name+"<==>OperatorId:"+item.Value);
foreach (varssiteminresult)
{
Console.WriteLine("CirleId:"+ssitem);
}
Console.WriteLine();
}
vermaanubhav...
Member
3 Points
39 Posts
Re: XML reading /parsing help required
Jan 31, 2013 06:24 AM|LINK
I doesnt mean that. Its returning value of operator id. But its not returning any value in this loop
foreach (var item in result)
{
var fresult = from items in doc.Descendants("CircleId")
where item.Equals(items)
select items;
foreach (var sitem in fresult)
{
//Do with Sqlcommand to save
}
}
and see how its returning output.
Its not even visible if its reliance or idea.
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: XML reading /parsing help required
Jan 31, 2013 06:51 AM|LINK
Hi again,
You cannot use item.Equals, because this will fetch all the CircleId's ToString() method, and it will match nothing.
Solution:
var fresult = from items in doc.Descendants("CircleId") where item.Value.Trim().Equals(OperatorId)vermaanubhav...
Member
3 Points
39 Posts
Re: XML reading /parsing help required
Jan 31, 2013 06:58 AM|LINK
ITs still giving me no results
var result = (from item in doc.Descendants("OperatorId") select item.Value).ToList(); foreach (var item in result) { var fresult = from items in doc.Descendants("CircleId") where item.Trim().Equals("OperatorId") select items; foreach (var sitem in fresult) { //Do with Sqlcommand to save } }and item does not have any property like item.Value
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: XML reading /parsing help required
Jan 31, 2013 07:02 AM|LINK
var result = (from item in doc.Descendants("OperatorId") select item.Value).ToList(); foreach (var item in result) { var fresult = from citem in doc.Descendants("CircleId") where citem.Value.Trim().Equals(item) select items; foreach (var sitem in fresult) { //Do with Sqlcommand to save } }vermaanubhav...
Member
3 Points
39 Posts
Re: XML reading /parsing help required
Jan 31, 2013 07:14 AM|LINK
Cant i get out put as Reliance 1
and Punjab and then circle id number. Its not clear atall for which product it is this circle id and which region its belong.
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: XML reading /parsing help required
Jan 31, 2013 07:37 AM|LINK
vermaanubhav...
Member
3 Points
39 Posts
Re: XML reading /parsing help required
Jan 31, 2013 07:41 PM|LINK
Thanks
A lot...