【问题标题】:how to pass data to Tbxml in iphone如何在iphone中将数据传递给Tbxml
【发布时间】:2013-02-20 19:43:02
【问题描述】:

我正在尝试使用 TBXML,我想通过发送用户名和密码来解析 xml,但不知道怎么做,我已经阅读了很多教程。

  -(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];
                        }
                    }
                }

【问题讨论】:

  • 代码的输出是什么?
  • 发布到 url 和解析 url 是不同的。
  • @sanjitshaw -sorry,但我想通过传递用户名和密码来使用这个 url 登录,但是如何做到这一点
  • 很好,但是您必须使用“POST”或“GET”将参数传递给服务器。在“GET”的情况下,您可以使用 url 传递参数,但在“POST”中,您必须在正文中传递参数,可以是“XML”或“JSON”。
  • 你为什么要深入研究 TBXML 来发出 http 请求。您应该查看 ASIHTTP Request 或 AFNetworking 以发出 http 请求。 TBXML 用于解析您可能响应 http 请求或来自某个文件的 xml。

标签: iphone ios objective-c tbxml


【解决方案1】:

把你的网址改成

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

您可以通过点击此链接Operation On String在运行时设置您的电子邮件和密码

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-10-22
    • 2021-05-29
    • 2019-05-08
    • 2017-01-08
    • 2014-04-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多