An error is reported in the iOS development background. Please check the XML format !!! Great gods

Source: Internet
Author: User
Error: Entity: line1: parsererror: Starttagexpected, & #039; & amp; lt; & #039; notfound is the request XML, which uses the ASIHTTPRequest request framework, I do not know where the error is & amp; lt ;? Xmlversion & #039; 1.0 & #039; encoding & #039; UTF-8 & #039; standalone & #039; yes & #039 ;? & Amp; gt; & amp; lt; R... error: Entity: line 1: parser error: Start tag expected, '<' not found
The following is the request XML, which uses the ASIHTTPRequest request framework. I do not know where the error is.
Com. portal. android. ExecuteAndroid ChangeState

Request data code:
NSString * kvr = [NSString stringWithFormat :@" ", @" ", Cell.shipnametextfield.text,cargoremark,self.doc kModel. t2, self. berthModel. t2, cargoType, self. cargoModel. t2, self. cargoModel. t1, cell. cargoWeightTextField. text, cell. billInfoTextField. text, @ "", cell. delegateTextField. text, @ "NODECL", appDelegate. userInfo. ORG_NAME, appDelegate. userInfo. ORG_ID, appDelegate. userInfo. USER_ID, appDelegate. userInfo. USER_NAME, appDelegate. userInfo. USER_ID, appDelegate. userInfo. USER_NAME, self. personModel. t2];
[Req sendRequest: @ "com. portal. android. ExecuteAndroid" metherName: @ "changeState" kvrStr: kvr andTag: 4001 andUrl: WebServeUrl];

  • (Void) sendRequest :( NSString) ClassPath metherName :( NSString) MetherName kvrStr :( NSString) KvrStr andTag :( NSInteger) tag andUrl :( NSString) Url
    {
    _ Block ASIHTTPRequest * request = [[ASIHTTPRequest alloc] initWithURL: [NSURL URLWithString: url];
    // NSLog (@ "% @", WebServeUrl );
    NSMutableString * requestXml = [[NSMutableString alloc] init];
    [RequestXml appendString :@" "];
    [RequestXml appendString :@" "];
    [RequestXml appendString :@" "];
    NSString * name = [NSString stringWithFormat :@" % @ % @ ", ClassPath, metherName];
    [RequestXml appendString: name];

    [RequestXml appendString: kvrStr];
    [RequestXml appendString :@""];
    [RequestXml appendString :@""];

    // NSLog (@ "% @", requestXml );
    NSData * requestData = [requestXml dataUsingEncoding: NSUTF8StringEncoding];

    [Request appendPostData: requestData];
    [Request setRequestMethod: @ "post"];

    // Return after the request is executed
    [Request setCompletionBlock: ^ {

    // NSLog (@ "Success"); NSData * decompressData = [request responseData]; GDataXMLDocument * doc = [[GDataXMLDocument alloc] initWithData: decompressData options: 0 error: Nil]; GDataXMLElement * rootElement = [doc rootElement]; NSArray * result = [rootElement elementsForName: @ "result"]; for (GDataXMLElement * response in result) {NSString * code = [[response attributeForName: @ "code"] stringValue]; NSString * Msg = [[response attributeForName: @ "msg"] stringValue]; // 01 is successful, and the rest are error if (! [Code isEqualToString: @ "01"]) {[self showAlert: msg];} else {NSArray * datasetArray = [rootElement elementsForName: @ "kvdata"]; NSArray * kvadaArray = [rootElement elementsForName: @ "dataset"]; GDataXMLElement * data = [kvadaArray objectAtIndex: 0]; NSArray * dataArray = [data elementsForName: @ "data"]; if ([datasetArray count]> 0) {[_ delegate didReceiveData: datasetArray andTag: tag] ;}else {[_ delegate didReceiveData: dataArray andTag: tag] ;}} request = nil;

    }];

    // Exception
    [Request setFailedBlock: ^ {

    // NSLog (@ "Failed"); [self showAlert: @ "Network request Failed. Please try again later"]; // [_ delegate didFairToReceiveData: nil andTag: tag];

    }];

    [Request startAsynchronous];
    }

Reply content:

Error: Entity: line 1: parser error: Start tag expected, '<' not found
The following is the request XML, which uses the ASIHTTPRequest request framework. I do not know where the error is.
Com. portal. android. ExecuteAndroid ChangeState

Request data code:
NSString * kvr = [NSString stringWithFormat :@" ", @" ", Cell.shipnametextfield.text,cargoremark,self.doc kModel. t2, self. berthModel. t2, cargoType, self. cargoModel. t2, self. cargoModel. t1, cell. cargoWeightTextField. text, cell. billInfoTextField. text, @ "", cell. delegateTextField. text, @ "NODECL", appDelegate. userInfo. ORG_NAME, appDelegate. userInfo. ORG_ID, appDelegate. userInfo. USER_ID, appDelegate. userInfo. USER_NAME, appDelegate. userInfo. USER_ID, appDelegate. userInfo. USER_NAME, self. personModel. t2];
[Req sendRequest: @ "com. portal. android. ExecuteAndroid" metherName: @ "changeState" kvrStr: kvr andTag: 4001 andUrl: WebServeUrl];

  • (Void) sendRequest :( NSString) ClassPath metherName :( NSString) MetherName kvrStr :( NSString) KvrStr andTag :( NSInteger) tag andUrl :( NSString) Url
    {
    _ Block ASIHTTPRequest * request = [[ASIHTTPRequest alloc] initWithURL: [NSURL URLWithString: url];
    // NSLog (@ "% @", WebServeUrl );
    NSMutableString * requestXml = [[NSMutableString alloc] init];
    [RequestXml appendString :@" "];
    [RequestXml appendString :@" "];
    [RequestXml appendString :@" "];
    NSString * name = [NSString stringWithFormat :@" % @ % @ ", ClassPath, metherName];
    [RequestXml appendString: name];

    [RequestXml appendString: kvrStr];
    [RequestXml appendString :@""];
    [RequestXml appendString :@""];

    // NSLog (@ "% @", requestXml );
    NSData * requestData = [requestXml dataUsingEncoding: NSUTF8StringEncoding];

    [Request appendPostData: requestData];
    [Request setRequestMethod: @ "post"];

    // Return after the request is executed
    [Request setCompletionBlock: ^ {

    // NSLog (@ "Success"); NSData * decompressData = [request responseData]; GDataXMLDocument * doc = [[GDataXMLDocument alloc] initWithData: decompressData options: 0 error: Nil]; GDataXMLElement * rootElement = [doc rootElement]; NSArray * result = [rootElement elementsForName: @ "result"]; for (GDataXMLElement * response in result) {NSString * code = [[response attributeForName: @ "code"] stringValue]; NSString * Msg = [[response attributeForName: @ "msg"] stringValue]; // 01 is successful, and the rest are error if (! [Code isEqualToString: @ "01"]) {[self showAlert: msg];} else {NSArray * datasetArray = [rootElement elementsForName: @ "kvdata"]; NSArray * kvadaArray = [rootElement elementsForName: @ "dataset"]; GDataXMLElement * data = [kvadaArray objectAtIndex: 0]; NSArray * dataArray = [data elementsForName: @ "data"]; if ([datasetArray count]> 0) {[_ delegate didReceiveData: datasetArray andTag: tag] ;}else {[_ delegate didReceiveData: dataArray andTag: tag] ;}} request = nil;

    }];

    // Exception
    [Request setFailedBlock: ^ {

    // NSLog (@ "Failed"); [self showAlert: @ "Network request Failed. Please try again later"]; // [_ delegate didFairToReceiveData: nil andTag: tag];

    }];

    [Request startAsynchronous];
    }

The request data is encrypted, and the data processed during request callback is not decrypted, resulting in an error.

The format is correct. You can use an ide that supports xml to check whether there is a syntax error...

Is there an error in the request data?
Can you post the code for printing the request data?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.