snehil_khanor 1 Light Poster

Worked like a charm.. Can you provide me with some links where I can learn about this technique more..??
Because I'll be needing to do many such fetching for my app..

What about this?

using System.Linq;
using System.Xml.Linq;

namespace DW_418207_CS_CON
{
   class Program
   {
      static void Main(string[] args)
      {
         XDocument doc = XDocument.Load("../../XmlFile1.xml");
         
         string strLink = (
            from x in doc.Descendants().First().Elements()
            where x.Name.LocalName.Equals("link")
            && x.Attribute("rel").Value.Contains("resumable-create-media")
            select x.Attribute("rel").Value
         ).FirstOrDefault();

         System.Diagnostics.Debug.WriteLine(strLink);
      }
   }
}

It looks like (and I assumed) "entry" is nested inside "feed".
If you want all of the links, it would not be too hard to modify the query to bring back a List<string>.

snehil_khanor 1 Light Poster

I cant change the layout as it is a response on Google docs API..

Hmmmm... it looks like Feed is your document element. This means that it is the highest level node and therefore every other node is a child of it. This being the case, you will need to simply loop through iterate through its child nodes until its child's element name is "entry". If you are able to change the layout of the xml doc, I would put feed as a child to an even higher parent:

<document>
   <feed>...</feed>
   <entry>...</entry>
</document>

This way you can load the feed child node and be sure that you won't have to parse entry nodes if you don't want to. Also, it's more organized to look at.

snehil_khanor 1 Light Poster

I have an xml like

<?xml version='1.0' encoding='UTF-8'?>
    <feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearch/1.1/' xmlns:docs='http://schemas.google.com/docs/2007' xmlns:batch='http://schemas.google.com/gdata/batch' xmlns:gd='http://schemas.google.com/g/2005' gd:etag='W/&quot;C0EARXY8eit7ImA9WhVREE0.&quot;'>
    
    <id>https://docs.google.com/feeds/default/private/full</id>
    <updated>2012-03-17T16:27:24.872Z</updated>
    <category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/docs/2007#item' label='item'/>
    
    <title>Available Documents - </title>
    
    <link rel='alternate' type='text/html' href='https://docs.google.com'/>
    <link rel='http://schemas.google.com/g/2005#resumable-create-media' type='application/atom+xml' href='https://docs.google.com/feeds/upload/create-session/default/private/full'/>
    <link rel='http://schemas.google.com/docs/2007#alt-post' type='application/atom+xml' href='https://docs.google.com/feeds/upload/file/default/private/full'/>
    <link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='https://docs.google.com/feeds/default/private/full'/>
    <link rel='http://schemas.google.com/g/2005#post' type='application/atom+xml' href='https://docs.google.com/feeds/default/private/full'/>
    <link rel='http://schemas.google.com/g/2005#batch' type='application/atom+xml' href='https://docs.google.com/feeds/default/private/full/batch'/>
    <link rel='self' type='application/atom+xml' href='https://docs.google.com/feeds/default/private/full/-/document'/>
    
    <some more tags />
    
    <entry gd:etag='&quot;E0UXTh9YDSt7ImBr&quot;'>
    <some more tags />
    <title>hi</title>
    <link rel='http://schemas.google.com/docs/2007#parent' type='application/atom+xml' href=''/>
    <link rel='alternate' type='application/atom+xml' href=''/>
    <link rel='http://schemas.google.com/docs/2007#embed' type='application/atom+xml' href=''/>
    <link rel='http://schemas.google.com/docs/2007#icon' type='application/atom+xml' href=''/>
    <link rel='http://schemas.google.com/g/2005#resumable-edit-media' type='application/atom+xml' href=''/>
    <link rel='http://schemas.google.com/docs/2007#alt-edit-media' type='application/atom+xml' href=''/>
    <link rel='http://schemas.google.com/docs/2007/thumbnail' type='application/atom+xml' href=''/>
    <link rel='self' type='application/atom+xml' href=''/>
    <link rel='edit' type='application/atom+xml' href=''/>
    <link rel='edit-media' type='application/atom+xml' href=''/>
    ...
    <some more tags />
    ...
    </entry>
    <entry>
    ...
    </entry>
    ...

I want to fetch The attribute "href" of the element <link> whose rel="http://schemas.google.com/g/2005#resumable-create-media"

What I'm doing right now is I'm getting list of nodes with xmlnode = doc.GetElementsByTagName("link"); then I'm iterating throught all of them and fetching the first one whose rel="http://schemas.google.com/g/2005#resumable-create-media"

So essentially m looping through all the nodes <link> when I'm just interested in those which are next child of node <feed> and are not inside node <entry>
A <feed> have multiple <entry> …

snehil_khanor 1 Light Poster

Thanx! That'll do.. but I was thinking if this can be done using RegEx.. I hear that thats much quicker and efficient..

snehil_khanor 1 Light Poster

I'm sending an HTTP POST request to google Client login and I'm getting this in respons:

SID=DQAAAGgA...7Zg8CTN
LSID=DQAAAGsA...lk8BBbG
Auth=DQAAAGgA...dk3fA5N

I used the below code to read the response:

Trace.WriteLine(new StreamReader(response.GetResponseStream()).ReadToEnd());

Now in this response i want to use only the value of Auth token. Can any one please help me on how to extract only that value from the response. Thanx!

snehil_khanor 1 Light Poster

I have an aplication that stores the data in a local MS access file now I want to move the data to the goOgle docs ans synt my MS Access files with goOgle docs.
I'm planning to store all my app documents in a specific folder on goOgle docs and then sync it with the MS access file.. As I'm having no prior experience of working on goOgle docs API so can any one please guide me in the right dfirection and if possible provide some resources (links to blogposts or forum threads) which can help me to do the above said task.
Also what should be the best way of syncing the data??

snehil_khanor 1 Light Poster

ohk! Now i think I might have asked it wrong..
see the scenario is smthng like this..
I have 10 checkboxes in a form... and what i want is when i right click on a checkbox and click edit on the contextmenu then the text value of the checkbox should change..
so what i want is to target the checkbox and that check box out of 10 on whihc i have right clicked..
where as sender object will return "Edit" as we are clicking on the Edit on the context menu.. got it?

snehil_khanor 1 Light Poster

Is there any way to return the name of the control I click on in a window form application using C#?
Using this pointer only returns form name.

snehil_khanor 1 Light Poster

hi,
php have thi svery nice function
strtoime()

int strtotime ( string $time [, int $now ] )
The function expects to be given a string containing an English date format and will try to parse that format into a Unix timestamp (the number of seconds since January 1 1970 00:00:00 UTC), relative to the timestamp given in now, or the current time if now is not supplied.

http://php.net/manual/en/function.strtotime.php

i was wondering if we have any similar function in C# also..

snehil_khanor 1 Light Poster

m using win7.. nd yes i installed in prog files..
and now the problem is solved.. but i still dont know how..
as i did number of things.. but i still wanna know the proper solution..

snehil_khanor 1 Light Poster

hi,
I'm working on a an app that uses access database so.. while making the setup file i added the file in the application folder along with the .exe file that uses it..
but after installation the .exe file is not able to alter the database as the user is not given the permission to write the database file which installer stored in application folder.
but when I run the exe as administrator it works fine..
so i could see two ways to get it right..
1) give write permissions over the database to the user..
2) olways by default run exe as admin
but I dont know how to do it..
any help would be appreciated...
thanx!

snehil_khanor 1 Light Poster

Yeah.. did that only.. Neways.. Thanks a lot for ur help :)

snehil_khanor 1 Light Poster

Have u seen the sticky note Gadget of windows Vista?
I am learning to make winApps on Visual Studio now a days.. so i thouht making it would be fun and learning... dats y..
so now can u suggest what to do so that no such issue occurs..

snehil_khanor 1 Light Poster

yeah.. got it..
But theres one more thing i wanna ask..
Out of these 4 forms there is 1 form which on closing closes all other 3 too.. but dats not the case with other 3 forms..
so y is dat? nd how to stop it?

snehil_khanor 1 Light Poster

yeah.. ur code is working..
can u please explain where was i going wrong?

snehil_khanor 1 Light Poster

but the problem is dat in this code

for (int i = 0; i < 4; i++)
                {
                    formarray[i] = new Form1();
                    formarray[i].Show();
                }

exception is generated at this line

formarray[i].Show();
snehil_khanor 1 Light Poster

no.. i wanna create "N" no. of forms.
where N = No. of records in a table
so i want a seperate form for every record in table..
getting me?

snehil_khanor 1 Light Poster

hmm.. tbut then wat should i do instead of this? ne suggestion?

snehil_khanor 1 Light Poster

Hey,
Can any one help me with this problem.. i'ld really appreciate ne help..
wat i wanna do is.. dat i want to dynamically create objects on a way that they could be created in a loop..
so i thot an array of object could help
so i went ahead and wrote this code in a form load event..

Form1[] formarray = new Form1[4];
for (int i = 0; i < 4; i++)
    {
        formarray[i] = new Form1();
        formarray[i].Show(); 
    }

but at the line

formarray[i].Show();

I get this exception

Error creating window handle.

As u mite have guessed from the code.. wat i wanna do is to open 'n' no. of forms while loading.. and n will differ every time .. actually it will depend upon the no of records in some table and i want the no. of forms to be equal to the no. of records.

snehil_khanor 1 Light Poster

well dat is giving the warning.. not this linking error..

snehil_khanor 1 Light Poster

Hi,
I have always programed in Turbo C 3.0 and little exp. with 4.5 but recently I installed Borland C++ Builder 6 and the environment is completely diifferent..
I was just testing some codes to get used to this new environment..
But this code below is giving an error i've never experienced before..
can any one pls help..
thnx in Advance..

/*EvaluatePrimeNo.cpp */

#include<iostream>
#include "EvaluatePrimeNo.h"
using namespace std;
bool EvaluatePrimeNo::isPrime(int a)
{
    int flag=0;
        for(int i=2;i<=a-1;i++)
        {
            if(a%i==0)
            {
                flag=0;
                break;
            }
            else
            {
                flag=1;
            }
            
        }
        if(flag==0)        
        return 0;
        else if(flag==1)
        return 1;
}

int main()
{
    EvaluatePrimeNo n;
    int num=94;
    cout<<n.isPrime(num);
}

/*EvaluatePrimeNo.h*/

class EvaluatePrimeNo {

public:
bool isPrime(int a);

};

and this is the error I'm getting..

[C++ Warning] EvaluatePrimeNo.cpp(24): W8070 Function should return a value
[Linker Fatal Error] Fatal: Could not open C:\Program Files\Borland\CBuilder6\Projects\Project1.exe (error code 5)
snehil_khanor 1 Light Poster

I want to test the code i wrote which is part of my assignment

double sine(double x, double tolerance, int & limit)
{
       int a = 1;
       double b = x;
       double z(0.0);
       do {
           b=(-z*x*x)/((2*a)*(2*a+1));
           z=b;
           z+=1;}
           while(fabs(b-z)>tolerance);
           limit= a;
           return b;
           }

im supposed to use a main() to test if the code works and im not sure how to do this
I would like a push in the right direction cause im stuck

I dont know wat u want to accoplish in this function.. but if u are asking how to call this function in main() .. then here it goes...

int main()
{
double x;
double tolerance;
int limit;
sine(x,tolerance,limit); //parameters here are called actual parameters 
}

the parameters that u wrote while defining fuction are called formal parameters.. and when we call a functio.. Actual parameters are copied into fromal parameters...

Hope it helps..
njjoy!
-Snehil :)

snehil_khanor 1 Light Poster

well by precedence I was not meaning which comes first in order.. but precedence rules of mathematics.. BODMAS ...
but anyway I've got the hint now how to solve this problem..
thnx again :)

snehil_khanor 1 Light Poster

thnx a ton.. :)

snehil_khanor 1 Light Poster

= is assignment operator which assigns a value to a variable ...
for e.g.
x=y; assigns y into x..
and == operator is used for equality
for e.g.
if(x==y)
{
some code;
}


njjoy!!
-Snehil :)

snehil_khanor 1 Light Poster

hi im davind from kaplan anw how to sum the whole thing

wat do u mean by sum?? wat exactly do u want??

snehil_khanor 1 Light Poster

We can use our standard string parsing algorithm. In this case, we can use find_first_of() since we will have multiple delimeters (+, -, *, and / for example)

string expression = "5+104-32/5";
string terms[20];
int prev=-1, curr=-1; 

while(curr_pos != string::npos)
{     
     prev_pos = curr_pos;     
     curr_pos = find_first_of("+-*/", prev_pos+1);      

     if(curr_pos != string::npos)           

          terms[i] = expression.substr(prev_pos+1, (curr_pos - prev_pos)); 
}

You can learn about other <string> class member here that will help you with your parsing needs.

Hope this helps to point ye' in the right direction. This is a basic string parsing algorithm for <string> class objects. This is untested code and may contain easy to fix errors.

I've never seen or used this technique before.. nd m sure there is some easier way also to do this .. as from where i got this problem.. this was files under level 1 problem.
although i've understood the approach given by you..
if i'm nt able to think of something else.. i'll sure use this to make sub strings and then convert the char to int type by using atoi function...
also i have to make a simlple calculator.. with only one operation at a time.. i.e only 5+4 at a time and not 5+4*3 bcoz dat will involve precedence rules...

snehil_khanor 1 Light Poster

yes u can .. but m afraid it would be an infinite loop...
your test condition is: s!='\0')|| s!=' '
which means if any of these two conditions is true then overall condition will be true which means loop will be incremented...
Here is the Truth table for OR:
False||False=False
False||True=True
True||False=True
True||True=True

which means condition will only be false when both conditions are false.. i.e loop will break only when s='\0' as well as =' ' at the same time .. which is not actually possible...

but if u want loop to be terminated.. then.. use AND
truth table for AND is:
False&&False=False
False&&True=False
True&&Fasle=False
True&&True=True

which implies condition will fail if any 1 of the condition is false.. i.e if s='/0' or ' ' any of these..
hope u get it..
njjoy!!
- Snehil :)

abhaymv commented: Good reply +1
snehil_khanor 1 Light Poster

Hey..
I wanna make a calculator .. which takes input as a string...
example:
Input : "1 + 2"
Output: 3
"1+2" is passed as a parameter which is in the format of a string. The return value is 3 which an integer format.

calculator needs only to perform +,*,-,/

i can make calculating logic myself.. jst m not able to think how to exrtract data from string..

thnx in advance :)