Giter Site home page Giter Site logo

xmlreader's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xmlreader's Issues

Producing different result when only one object is shown upon request

I have an object c code connecting to a web server returning an xml.
after, I put the result into an NSDictionary:

self.xmlDictionary = [XMLReader dictionaryForXMLString:self.theXML options:XMLReaderOptionsProcessNamespaces error:&parseError];
NSLog(@"%@", self.xmlDictionary);

If my JSON returns more than 1 object my code counts the objects perfectly. But if my JSON returns only ONE object it miscounts.

My guess is the parenthesis are not inserted when only one value is returned.

Check my stack with complete code please:
http://stackoverflow.com/questions/33659623/objective-c-miscounting-array-with-json

Difference in result dictionary between old XMLReader and current

Can I get result dictionary like on old version of XMLReader?

NSString *xmlString = @"<items><one id=\"1\">1</one><two><some>Test</some><some>Test2</some></two><three id=\"3\">3</three><four>4</four></items>";

Old XMLReader output

{
    items =     {
        four = 4;
        one =         {
            "@id" = 1;
            text = 1;
        };
        three =         {
            "@id" = 3;
            text = 3;
        };
        two =         {
            some =             (
                Test,
                Test2
            );
        };
    };
}

New XMLReader output:

{
    items =     {
        four =         {
            text = 4;
        };
        one =         {
            id = 1;
            text = 1;
        };
        three =         {
            id = 3;
            text = 3;
        };
        two =         {
            some =             (
                                {
                    text = Test;
                },
                                {
                    text = Test2;
                }
            );
        };
    };
}

After parsing is complete when you set the Text property value is a special error

I have an XML document, in the following format:

<?xml version="1.0" encoding="utf-8"?>
<vcread>
  <bg_img id="32" title="背景(7)" x="0" y="0" width="320" height="480" src="333_07.jpg" tag="" seq="0" />
  <item>
    <text id="33" title="文本" x="19" y="309" width="284" height="166" type="char" content="ContentText"/>
  </item>
</vcread>

Your code:

- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
    // Update the parent dict with text info
    NSMutableDictionary *dictInProgress = [self.dictionaryStack lastObject];

    // Set the text property
    if ([self.textInProgress length] > 0)
    {
        // trim after concatenating
        NSString *trimmedString = [self.textInProgress stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
        [dictInProgress setObject:[trimmedString mutableCopy] forKey:kXMLReaderTextNodeKey];

        // Reset the text
        self.textInProgress = [[NSMutableString alloc] init];
    }

    // Pop the current dict
    [self.dictionaryStack removeLastObject];
}

When the analysis is completed, item-> text has been nil, I debugged the code, find item-> text after the first, was reset to nil, so I modified the code and commit, please test,thank you

Cocoapods Support

Would you mind adding this to cocoapods? If you don't I'm going to end up forking and doing it myself

ARC Issue

XCode generates a "Pointer to non-const type" error on this line now:
NSError **errorPointer;

I'm not sure of the best workaround.

CData Not parsing

First of all thanks for creating this great parser that helped me a lot.

Now i know that CData means you have to ignore while parsing, but in case i need to parse it then how can i do it?

I found one method in NSXMLParserDelegate and i implemented it as below. The problem is how to place the string parsed exactly where it belongs.

-(void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock
{
NSString *someString = [[NSString alloc] initWithData:CDATABlock encoding:NSUTF8StringEncoding];
// Build the text value
[self.textInProgress appendString:someString];
NSLog(@"-------CData String %@",someString);
}

Parsing issue

Is it possible to create key-value pair?
Rather then adding a node key "text".

Thanks in advance.

XMLReader init with NSError ** NULL

Hey,
great class you made here. I just want to notify it crashing when NSError **error equals NULL (which happens, quite often to me), and since you try to dereference the error in the init method (initWithError), it crashes. One way of solving this might be rewriting it as

if (error != NULL) self.errorPointer = *error;

what do you think?

Thanks,
G.

Conflicting Parameter Types Warning

For the initWithError method declaration, this is given:

  • (id)initWithError:(NSError **)error;

Which differs from the implementation:

  • (id)initWithError:(NSError*)error

This causes a warning in Xcode and I was wondering whether this could be fixed as my efforts to make them the same only led to more warnings.

Distribution permission from owner

Hi
Can you please confirm that original owner of this code Mr. Troy has given you distribution permission free of cost as license file is not mentioning about the same.
Our Open Source Scan team has been raised a concern for this and they want a formal confirmation for same for one of our commercial project.
Your timely reply really appreciate on this topic.
thanks Jatin

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.