Conversion between IOS xml and NSDictionary

Source: Internet
Author: User

Conversion between IOS xml and NSDictionary

Introduction:

In ios, xml files or strings are often converted to NSDictionary;

Requirements:

The format of web Server requests and returned data is xml. controls need to be dynamically generated based on the parsed xml file. The form may be filled with values and must be saved temporarily. A form contains content, with only the id of the form, name;

If the value is set in the form, add the value to it.

1

2 ewew

2 ewew

..................

 

Find innertext in the XMLDictionary. m file and modify it as follows:

-(Id) innerText
{
Id text = self [XMLDictionaryTextKey];
If ([text isKindOfClass: [NSArray class])
{
Return [text componentsJoinedByString: @];
}
Else
{
// Judge whether the value is null
If ([(NSString *) text length] = 0 ){
Return @;
} Else
Return text;
}
}

 

After the above modification, No matter 1, Or 2, 4424

Both xml and NSDictionary can be converted to each other;

Otherwise

The following situations occur:



1,

Dictionary :{
_ Name = transactions;
}

XMLString ============
======

After modification

Dictionary :{
_ Name = transactions;
Transaction = {
Head =;
};
}

MLString ============


======

 

 

 

Related Article

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.