Dong this is the problem with this xml. There is not a fixed operator id for a particular circle. In that xml there are more than 100 circles with different name and 15 operators. If i go on writing every operator and circles in .net code then manual copying
of data from xml would be easier and faster than to create the program. as I am manually entering the circle id and circle name.
You can first fetch all the Values of OperatorIds and continue:
var result = (from item in XDocument.Descedants("OperatorID")
select item.Value).ToList();
var fresult = from item in XDocument.Descedants("CirculeID")
where result.IndexOf(item.Value)>=0
select item;
Hi Dong thanks for replying. I tried similar type of it before its giving me strange output as 00001blank and other stuff..
XDocument doc = XDocument.Load("http://mobile.onestoprecharge.net/reseller/ResellerFlexiVouchersAPI.php?reseller_id=741&reseller_pass=123456");
var result = (from item in doc.Descendants("Reliance")
select item.Value).ToList();
var fresult = from item in doc.Descendants("Circles")
where result.IndexOf(item.Value) >= 0
select item;
Here is the code which I am trying.
This result returning output as 10Blank000001Blank000002Blank000003Blank000004Blank000005Blank000008Blank000009Blank0000010Blank0000011Blank0000012Blank0000013Blank0000014Blank0000016Blank0000018Blank0000020Blank0000025Blank00000
and Also in xml if you minimise i am just interested in the following data
So you have to fetch one operatorID and then fetch its all CircleID and do saving:
var result = (from item in XDocument.Descedants("OperatorID")
select item.Value).ToList();
foreach(var item in result)
{
var fresult = from item in XDocument.Descedants("CirculeID")
where item.Value ==item
select item;
foreach(var sitem in fresult)
{
//Do with Sqlcommand to save
}
}
Please see the screenshot attached. And the response its giving. ....
XDocument doc = XDocument.Load("http://mobile.onestoprecharge.net/reseller/ResellerFlexiVouchersAPI.php?reseller_id=741&reseller_pass=123456");
var result = (from item in doc.Descendants("Reliance")
select item.Value).ToList();
foreach (var item in result)
{
var fresult = from items in doc.Descendants("CircleID")
where item.Equals(items)
select item;
foreach (var sitem in fresult)
{
//Do with Sqlcommand to save
}
}
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: XML reading /parsing help required
Jan 31, 2013 02:45 AM|LINK
Hi,
You can try with XDocument to cope with the problem:
var result = from item in XDocument.Descedants("CircleId")
where item.Value == "Your own OperatorID here"
select item;
vermaanubhav...
Member
3 Points
39 Posts
Re: XML reading /parsing help required
Jan 31, 2013 02:49 AM|LINK
Dong this is the problem with this xml. There is not a fixed operator id for a particular circle. In that xml there are more than 100 circles with different name and 15 operators. If i go on writing every operator and circles in .net code then manual copying of data from xml would be easier and faster than to create the program. as I am manually entering the circle id and circle name.
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: XML reading /parsing help required
Jan 31, 2013 02:52 AM|LINK
Hi again,
You can first fetch all the Values of OperatorIds and continue:
var result = (from item in XDocument.Descedants("OperatorID") select item.Value).ToList(); var fresult = from item in XDocument.Descedants("CirculeID") where result.IndexOf(item.Value)>=0 select item;vermaanubhav...
Member
3 Points
39 Posts
Re: XML reading /parsing help required
Jan 31, 2013 03:44 AM|LINK
Hi Dong thanks for replying. I tried similar type of it before its giving me strange output as 00001blank and other stuff..
XDocument doc = XDocument.Load("http://mobile.onestoprecharge.net/reseller/ResellerFlexiVouchersAPI.php?reseller_id=741&reseller_pass=123456");
var result = (from item in doc.Descendants("Reliance")
select item.Value).ToList();
var fresult = from item in doc.Descendants("Circles")
where result.IndexOf(item.Value) >= 0
select item;
Here is the code which I am trying.
This result returning output as 10Blank000001Blank000002Blank000003Blank000004Blank000005Blank000008Blank000009Blank0000010Blank0000011Blank0000012Blank0000013Blank0000014Blank0000016Blank0000018Blank0000020Blank0000025Blank00000
and Also in xml if you minimise i am just interested in the following data
for all the nodes under <operators>
I have to save this xml in database in following way....
Table 1
Reliance 1 (opertor ID)
Idea 2 (operator ID)
Table 2
Punjab 1(CircleID) 1(Foreign key to reliance)
All State 0(CircleID) 1(Foreign key to reliance)
and so on.
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: XML reading /parsing help required
Jan 31, 2013 04:06 AM|LINK
Hi again,
So you have to fetch one operatorID and then fetch its all CircleID and do saving:
var result = (from item in XDocument.Descedants("OperatorID") select item.Value).ToList(); foreach(var item in result) { var fresult = from item in XDocument.Descedants("CirculeID") where item.Value ==item select item; 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 04:19 AM|LINK
Please see the screenshot attached. And the response its giving. ....
XDocument doc = XDocument.Load("http://mobile.onestoprecharge.net/reseller/ResellerFlexiVouchersAPI.php?reseller_id=741&reseller_pass=123456"); var result = (from item in doc.Descendants("Reliance") select item.Value).ToList(); foreach (var item in result) { var fresult = from items in doc.Descendants("CircleID") where item.Equals(items) select item; foreach (var sitem in fresult) { //Do with Sqlcommand to save } }OperatorId returns null or no value here.
Operators return the same output as 10Blank.....
vermaanubhav...
Member
3 Points
39 Posts
Re: XML reading /parsing help required
Jan 31, 2013 04:33 AM|LINK
See the output. The descendants of Reliance is coming as 10Blank000000.
If you see this you will understand that how we are getting output.
We can get it in better form like...
Reliance 1
Circles 0
Punjab 1
etc....
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: XML reading /parsing help required
Jan 31, 2013 06:00 AM|LINK
Hi again,
Why do you use Reliance instead of OperatorID?
vermaanubhav...
Member
3 Points
39 Posts
Re: XML reading /parsing help required
Jan 31, 2013 06:03 AM|LINK
Because OperatorId returns 0 values in result...
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: XML reading /parsing help required
Jan 31, 2013 06:10 AM|LINK
Sorry it's case-sensitive, you should write OperatorId