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 ============
======