Comments (2)
Hi, sorry for the delay. I assume that you have found a solution by now.
Would you mind to share it or open a PR with it?
I am trying to clean my issues and give that repository more attention than during the past.
from xmlreader.
Actually i have implemented the above method nothing new.
But sure i want to share following method which i used to clean-up the NSDictionary and generate the better output of the XML.
- First parse the XML using XMLReader.
- Than pass that dictionary into following method and compare before and after clean-up dictionary.
- I have changed NSString *const kXMLReaderTextNodeKey = @"temp"; in XMLReader.
#define kXMLDefaultKey @"text"
/**
* This method is used to clean up dictionary which we get after XML parsing
*
* @param XMLDictionary Dictionary on which we want to perform cleanup
*
* @return Cleaned dictionary
*/
+ (NSMutableDictionary *)cleanUpXMLDictionary:(NSMutableDictionary *)XMLDictionary
{
for (NSString *key in [XMLDictionary allKeys]) {
// get the current object for this key
id object = [XMLDictionary objectForKey:key];
if ([object isKindOfClass:[NSDictionary class]]) {
if ([[object allKeys] count] == 1 &&
[[[object allKeys] objectAtIndex:0] isEqualToString:kXMLDefaultKey] &&
![[object objectForKey:kXMLDefaultKey] isKindOfClass:[NSDictionary class]]) {
// this means the object has the key "text" and has no node
// or array (for multiple values) attached to it.
[XMLDictionary setObject:[object objectForKey:kXMLDefaultKey] forKey:key];
}
else {
// go deeper
[self cleanUpXMLDictionary:object];
}
}
else if ([object isKindOfClass:[NSArray class]]) {
// this is an array of dictionaries, iterate
for (id inArrayObject in (NSArray *)object) {
if ([inArrayObject isKindOfClass:[NSDictionary class]]) {
// if this is a dictionary, go deeper
[self cleanUpXMLDictionary:inArrayObject];
}
}
}
}
return XMLDictionary;
}
from xmlreader.
Related Issues (14)
- ARC Issue HOT 5
- Cocoapods Support HOT 2
- XMLReader don't give data in correct format if there is only 1 object HOT 1
- XMLReader init with NSError ** NULL HOT 1
- Producing different result when only one object is shown upon request HOT 1
- After parsing is complete when you set the Text property value is a special error
- Add License Declaration to each Source file
- Distribution permission from owner
- Parsing issue HOT 1
- crash on parser release HOT 1
- Difference in result dictionary between old XMLReader and current HOT 1
- Add support for SOAP tags HOT 1
- Conflicting Parameter Types Warning HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xmlreader.