2

i am trying to use TBXML, i want to parse xml by sending username and password but dnt how to do it, i have already gone through many tutorials.

  -(IBAction)login{
                    NSString *str2=emailtxt.text;
                    NSString *str3=passtxt.text;

                    TBXML * tbxml = [TBXML tbxmlWithURL:[NSURL URLWithString:@"http://www.vinipost.com/my_service.asmx/signIn"]];


                    TBXMLElement *rootXMLElement = tbxml.rootXMLElement;

                    if (rootXMLElement)
                    {
                        TBXMLElement * user = [TBXML childElementNamed:@"Table1" parentElement:rootXMLElement];

                        while (user != nil)
                        {

                            TBXMLElement *CountryId = [TBXML childElementNamed:@"usrid" parentElement:user];
                            if (CountryId != nil)
                            {
                                NSLog(@"CountryId :: %@", [TBXML textForElement:CountryId]);
                            }

                            TBXMLElement *CountryName = [TBXML childElementNamed:@"ContctNmbr" parentElement:user];
                            if (CountryName != nil)
                            {
                                NSLog(@"CountryName :: %@", [TBXML textForElement:CountryName]);
                            }

                            user = [TBXML nextSiblingNamed:@"Table1" searchFromElement:user];
                        }
                    }
                }
Vivek Sehrawat
  • 6,560
  • 2
  • 26
  • 39
  • What is the output for your code? – Ganapathy Mar 06 '13 at 06:20
  • Posting to a url and parsing a url are different. – Exploring Mar 06 '13 at 06:21
  • @sanjitshaw -sorry but i want to login with this url by passing username and password, but how to do it – Vivek Sehrawat Mar 06 '13 at 06:23
  • 1
    Fine, but you have to pass parameters to server either using "POST" or "GET". In case of "GET" u can pass parameters with the url but in "POST" u have to pass parameters in body which may be either "XML" or "JSON". – Exploring Mar 06 '13 at 06:32
  • @VivekSehrawat Thanks. I'll try, but I'd like to know about the url. Are u using soap? I'm asking because it is a .asmx url. – Exploring Mar 06 '13 at 06:52
  • @sanjitshaw- these web services are made in C# in .net platform using soap – Vivek Sehrawat Mar 06 '13 at 06:56
  • 1
    Why are you digging into TBXML for making http requests. You should be looking into ASIHTTP Request or AFNetworking for making http requests. TBXML is used for parsing xmls that you may get in response to an http request or from some file. – SayeedHussain Mar 06 '13 at 07:08

1 Answers1

1

Change your URL to

[NSURL URLWithString:@"http://www.vinipost.com/my_service.asmx/signIn?email=yourEmail&pass=yourPass"];

You can set your email and password on runtime by following this link Operation On String

Rajneesh071
  • 30,846
  • 15
  • 61
  • 74