Giter Site home page Giter Site logo

rapturexml's People

Contributors

alexsmith84 avatar buscarini avatar gbh avatar gcamp avatar grahamcracker avatar jasperblues avatar ksslng avatar mbaltaks avatar padraigk avatar readmecritic avatar samvermette avatar siuying avatar wallclimber21 avatar zablanc avatar zoul avatar

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

rapturexml's Issues

Support for elements containing a period (.)

I understand that a period is valid character in an XML element tag. Short of doing a replaceOccurrencesOfString on the entire XML prior to parsing, there should be support to escape a period in the xml query ie:

[resultXML child:@"SYSTEM\.DATE"]

Please add semantic version tags.

I want to add RaptureXML to the CocoaPods package manager repo.

CocoaPods is a tool for managing dependencies for OSX and iOS Xcode projects and provides a central repository for iOS/OSX libraries. This makes adding libraries to a project and updating them extremely easy and it will help users to resolve dependencies of the libraries they use.

However, RaptureXML doesn't have any version tags. I will add the current HEAD as version 0.0.1, but a version tag will make dependency resolution much easier.

Semantic version tags (instead of plain commit hashes/revisions) allow for resolution of cross-dependencies.

In case you didn’t know this yet; you can tag the current HEAD as, for instance, version 1.0.0, like so:

$ git tag -a 1.0.0 -m "Tag release 1.0.0"
$ git push --tags

Add a license file

It would be awesome if you added a license file for CocoaPods which likes to be able to tell users the license of the library ahead of time. All you'd have to do is add a LICENSE*.* file to the root of the project and add a new podspec for the new tag.

Thanks!

CocoaPods

I get for the pod:

Undefined symbols for architecture i386:
"_xmlDocGetRootElement", referenced from:
-[RXMLElement initFromXMLString:encoding:] in libPods.a(RXMLElement.o)
-[RXMLElement initFromXMLFile:] in libPods.a(RXMLElement.o)
-[RXMLElement initFromXMLFile:fileExtension:] in libPods.a(RXMLElement.o)
-[RXMLElement initFromURL:] in libPods.a(RXMLElement.o)
-[RXMLElement initFromXMLData:] in libPods.a(RXMLElement.o)
"_xmlFree", referenced from:
-[RXMLElement text] in libPods.a(RXMLElement.o)
"_xmlFreeDoc", referenced from:
-[RXMLElement initFromXMLString:encoding:] in libPods.a(RXMLElement.o)
-[RXMLElement initFromXMLFile:] in libPods.a(RXMLElement.o)
-[RXMLElement initFromXMLFile:fileExtension:] in libPods.a(RXMLElement.o)
-[RXMLElement initFromURL:] in libPods.a(RXMLElement.o)
-[RXMLElement initFromXMLData:] in libPods.a(RXMLElement.o)
-[RXMLElement dealloc] in libPods.a(RXMLElement.o)

Do you know how to fix it?

Parsing XML with same keys but different attributes

Hi all,

I'm parsing an RSS feed that looks like this for the items :

<item>
    <id>29</id>
    <ns:zone lang="fr">Centre</ns:zone>
    <ns:zone lang="de">Zentrum</ns:zone>
</item>

if I make this :

NSArray* items = [[rss child:@"channel"] children:@"item"];
for (RXMLElement *e in items) {
}

I only get the first item with attribute lang ="fr".

What should I do to have the value of the lang="de" ?
Any idea ? (PS : I'm not the owner of the RSS, i can't change it)

Thanks a lot !
Arnaud

Define a module map for libxml2

If I use use_frameworks! with Cocoapods and include the RaptureXML pod, it fails to compile. See CocoaPods/CocoaPods#3654 (comment)

This can be recreated by setting up a new single view project and adding the RaptureXML pod with use_frameworks! set in the pod.

On that linked issue, while we wait for Apple to provide the module map, they suggest defining your own for libxml in your Cocoapod like this:
https://github.com/neonichu/SQLite.swift/blob/master/SQLite.swift.podspec#L25-L33

XCode 4.2 and iOS5 issues

Off the box XCode compilation enforces static analysis, that triggers issues in TBXML source files ("Dereference of null pointer" and "The left operand of '&' is a garbage value").

Automatic Reference Counting

I have 22 errors and it looks like they are all due to ARC being on. Is there a way to change all of the "return [[[RXMLElement alloc] initFromXMLData:data] autorelease];" like returns to arc friendly returns?

Parsing RSS via RaptureXML

How to work with tags itunes:summarytext</itunes:summary>?

These following codes does not work:

episode.summary = [item child:@"summary" inNamespace:@"itunes"].text;

or

episode.summary = [item child:@"summary:itunes"].text;

CocoaPod + Mac

RaptureXML works flawlessly Mac, but it's listed in CocoaPods as iOS only.
Please add the necessary metadata for Mac support in Cocoapods.

Issues with non-unicode character

Given the following XML (not escaped - edit issue to see the XML):

<xml_api_reply version="1">

<forecast_information>

<postal_code data="paris"/>
<latitude_e6 data=""/>
<longitude_e6 data=""/>
<forecast_date data="2012-07-12"/>
<current_date_time data="2012-07-12 13:56:00 +0000"/>
<unit_system data="US"/>
</forecast_information>

</xml_api_reply>

Rapture is returning null for the city with this code (category on RaptureXML):

  • (PFWeatherReport*) asWeatherReport {
    if (![self.tag isEqualToString:@"weather"]) {
    [NSException raise:NSInvalidArgumentException format:@"Element is not 'weather'."];
    }

    NSDateFormatter* dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"yyyy-MM-dd"];

    //CITY IS COMING BACK AS NULL!!!!!
    NSString* city = [[self child:@"forecast_information.city"] attribute:@"data"];
    NSDate* forecastDate =
    [dateFormatter dateFromString:[[self child:@"forecast_information.forecast_date"] attribute:@"data"]];
    PFCurrentConditions* currentConditions = [[self child:@"current_conditions"] asCurrentConditions];

    NSMutableArray* forecast = [NSMutableArray arrayWithCapacity:5];
    for (RXMLElement* e in [self children:@"forecast_conditions"]) {
    [forecast addObject:[e asForecastConditions]];
    }

    return [PFWeatherReport reportWithCity:city date:forecastDate currentConditions:currentConditions
    forecast:forecast];
    }

How to iterate without usingBlock?

Hello,
I really enjoy using RaptureXML. Thank you.

Is there a way to iterate without using block?
I would like to do iteration inside subclass of NSOperation for concurrency.
However, if I use block, I will not be able to cancel iteration process.
Thanks for any pointers you can provide.

Podcast RSS support

RaptureXML doesn't parse property when the tag has colon in it, such as itunes:duration.

Android/Java port

Hi,
I have ported rapture xml to Java on top of the java TBXML.

Mind if I upload to my github.

BIG XML file

hi i have a 50 mb xml file
im the ios simulator it work ok
but in a real ipad it crash

how much big a xml could be? or what could i dp?

Issue integrating RaptureXML through Cocoapods

Hi

I am trying to include RaptureXML through Cocoapods. My Podfile look like:

pod 'RaptureXML', '~> 1.0.1'

My project is a "Static Library" project. I get following error:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: -dynamic not specified the following flags are invalid: -ObjC
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't locate file for: -lxml2
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: -lxml2 is not an object file (not allowed in a library)
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't locate file for: -lz
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: -lz is not an object file (not allowed in a library)

There is following added to "Pods.debug.xcconfig":

OTHER_LDFLAGS = -l"xml2" -l"z"

If I remove above two libraries from "OTHER_LDFLAGS", it compiles fine. But these two are specified in "RaptureXML" Podspec.

Any help is appreciated.

Thanks
Gaurav Agarwal

Release-Mode ARC Problem / Copy RXMLElement?

I have an iOS app that uses RaptureXML, which works flawlessly in Debug mode. However, when I target compilation for Release, I run into issues.

My app interfaces with an XML API, so I wrote a "call" function that uses RaptureXML to retrieve an RXMLElement, which is returned by the function. Here is this function used in the view controller:

...
RXMLElement* add_test = [api call:@"accountAdd" withParams:add_params];
NSLog(@"add_test result: %@", add_test);
...

In Release mode, that NSLog() shows that add_test is blank. I put in a breakpoint to examine, and I see that add_test does not have a memory address:

Ok, so there must be something with the call function. However, here is the code in the call function:

- (RXMLElement*) call:(NSString*) api_name withParams:(NSString*) params withResult:(BOOL) result{
    ...
    RXMLElement* result_base = [base child:@"Result"];
    if([api_name isEqualToString:@"accountAdd"]){
        NSLog(@"add_test result from call: %@", result_base);
    }
    return result_base;
}

Above, I NSLog() result_base before it is returned- and when this happens, I see the XML text of the object!

So the RXMLElement* does exist before it is returned, but when I try to use it after the function has been called, it is deallocated. I can only guess that for some compiler optimization for Release mode, the object is being destroyed.

My question is, (1) Is there some way to copy RXMLElement* objects so they are not destroyed when the parent "document" goes out of scope, or (2) is there some other way I can keep the object from being destroyed?

Thank you very much for creating such a great library.

Get <array> data

I have the following XML:

'










'

How can I iterate through the array of mapped items and get pertaining values for name and location?

filter by attribute, or xpath on non-root node

Maybe I'm missing something, but is it possible to filter by attribute without using xpath? I want to be able to retrieve an element, then retrieve children of that element that have a particular attribute value. I can almost do it with xpath, but since all the queries seem to be from the document root I can't narrow my search to a particular element.

I'm envisioning something like [element children:@"otherElement[attributeName='attributeValue']"]

If it's possible to scope xpath queries to a particular parent node that would solve my problem too.

SAFE_ARC_AUTORELEASE not working as intended

I'm using the head of RaptureXML through CocoaPods and I'm seeing odd behaviors with the SAFE_ARC_AUTORELEASE macro. My project uses ARC, but somehow my RXMLElement objects keep getting prematuraly released.

Issue is fixed if I remove SAFE_ARC_AUTORELEASE completely.

I noticed that the podspec doesn't have requires_arc property so I'm thinking this might be the source of the problem. That being said I'm not sure what the right fix is. Perhaps ARC has been out long enough that the master branch can be ARC only?

Alternatively, anyone who's not using ARC in their project can add an ARC-only lib by adding the -fobjc-arc compiler flags to the .m files.

Badly formed XML

Badly formed XML should throw?

Steps to Reproduce:

RXMLElement* element = [RXMLElement elementFromXMLString:@"</xml"]; //Missing closing tag.

Result:

EXEC_BAD_ACCESS

Expected:

Throws RXMLBadlyFormedException

it should be modified to release at right time

  • (id)elementFromXMLDoc:(RXMLDocHolder *)doc node:(xmlNodePtr)node {
    return [[[RXMLElement alloc] initFromXMLDoc:doc node:node]autorelease];
    }

some places i think should add the word autorelease

RaptureXML performance

Would you care to add your code to Ray Wenderlich's XML Parser comparison? It would be amazing to see real numbers – especially because you claim libxml2 to be faster than TBXML, which is not what the performance shootout on Ray's site claims.

Thanks for your project!

Wait to iterate to finish

Is there any solutions to wait for the ITERATE methods to finish?

I have something like this:

[element iterate:@"*" usingBlock:^(RXMLElement * blk) {
    if ([blk.tag isEqualToString:STATUS_TAGNAME]) {
        [subelements addObject:blk];
    }
}];

if (subelements && ([subelements count] > 0)) {
    RXMLElement *subElement = (RXMLElement*)[subelements objectAtIndex:0];
    status = subElement.textAsInt;
}

And I need to the ARRAY subelements to be completed.

Any sugestions?

Many thanks!

License

What is the license that you have on this. I don't see on anywhere on your site or in the project.

PS you're the man.

Out-of-date tags prevents use of RXMLElement's 'xml' property from CocoaPods

The 'xml' property on the RXMLElement class is available on master, but was added after the last tag in the podspec.

In order to use the 'xml' property, this repo will need an updated tag (say, 1.0.2) and the podspec will also need to be updated to reference that tag.

Until then, it is not possible to integrate with the latest version of RaptureXML using CocoaPods.

I will fork the repo to update the podspec on my end and will submit a pull request. However, this will update the podspec and not the tags on the repo. (I don't believe there's a way to generate a pull request that says "apply this tag to the master branch".)

Feel free to reach out to me directly for more info on this issue.

And thanks for all your work on RaptureXML. It's been a great resource for us!

-[RXMLElement text] only works on leaf nodes?

Calling -[RXMLElement text] on any child node in my parsed XML properly returns whatever text was contained in the tag. But when I call -[RXMLElement text] on a non-child node in my XML, I get a null string. I was expecting to get all contained XML.

For example, with the following XML:

<topLevel>
<secondLevel>
<thirdLevel>
Here is some text
</thirdLevel>
</secondLevel>
</topLevel>

[thirdLevelElement text] returns "Here is some text", while [secondLevelElement text] and [topLevelElement text] return null. Am I wrong to expect XML to be returned through this method? Or is this a bug?

Finally, the important question: Is there a way to retrieve the XML contained within a given tag?

Thanks.

Small "typo" in readme.md

Very small thing, but made me a lose a bit of time, so I figured i'd report it so it wouldn't happen to other noobs:

[rootXML iterateWithRootXPath:@"//player[number='5']" usingBlock: ^(RXMLElement *player) {
NSLog(@"Player #5: %@", [player child:@"name"]);
}];

where it reads [number='5'], it should read [@Number='5']. It's missing the "@".

Great work though. Loving RaptureXML!

NSArray of all children in a tag

Great work with this project, it is very useful. I do have a question:

In your example, you show how I can get all players in the tag:
NSArray *rxmlIndividualPlayers = [rxmlPlayers children:@"player"];

My question would be, how do I get all players and the coach from the tag?
I tried using a wildcard, but it didn't work:
NSArray rxmlIndividualPlayers = [rxmlPlayers children:@""];

Thanks,

How to parse the xml inside one xml

Sorry, don't know how to post html tag here.

I need some help here, I want to parse the xml inside one xml and get the text of the node, but I cannot get it working, my xml looks like below:

2 <title type="text">Marina</title> Marina/d:Area 1.2911/d:Latitude 103.8575/d:Longitude 0/d:Distance /m:properties

Please tell me how to get the text of m:Area by using RaptureXML? really appreciate your help, thanks.

Error README.md code example

Thanks for the creating and sharing this library. This is a very minor issue, but thought you might like to know...

If you look at the first code sample in the README (under "Why do we need another XML library?"):

[rootXML iterate:@"players.player" usingBlock: ^(RXMLElement *e) {
    NSLog(@"Player #%@: %@ (%@)", [e attribute:@"number"], [e child:@"name"].text);
}];

The NSLog command has three %@ placeholders, but you are only providing two additional arguments. I'm guessing that you accidentally left out [e child:@"position"].text?

A *stop block variable to break from iterating?

Kudos for creating an awesome, super easy to use XML library!

One minor feature request:

Could you add a "stop" variable to the -[iterate:with:] method?

Like

[rootXML iterate:@"players.player" with: ^(RXMLElement *e, *stop) {
NSLog(@"Player #%@: %@ (%@)", [e attribute:@"number"], [e child:@"name"].text);
*stop = YES; // Similar to "break" in for loops
}];

Support for true XPath

Thanks for this great XML-Library, looks awesome. What would be even more awesome would be XPath-support for querying, possibly with the use of libxml. I might be willing to help, if you want to add this feature.

Iterating over attributes

Really enjoying using Rapture so far.

Any way to iterate over the attributes of a node though? I'm looking for a way to get all attribute names and values of a node without having to know the names of the attributes ahead of time.

How about adding XML modification/updating support like follows

/**
 *  Update xml node values that matching specified XPath with feeded new value list.
 *  Note that the new value list can contain only one item which will be used to
 *  replace all matching nodes in xml, or contain just enough values to replace all matching nodes.
 *
 *  @param xpath
 *  @param nodeValue New value list, must have at least one item
 *
 *  @return
 */
- (BOOL) updateXpath:(NSString*)xpath withNewNodeValues:(NSArray *)nodeValue {

    xmlDocPtr doc = [self.xmlDoc doc];
    xmlXPathContextPtr xpathCtx;
    xmlXPathObjectPtr xpathObj;
    /* Create xpath evaluation context */
    xpathCtx = xmlXPathNewContext(doc);
    if (NULL == xpathCtx) {
        return NO;
    }
    /* Evaluate xpath expression */
    xpathObj = xmlXPathEvalExpression((xmlChar *)[xpath cStringUsingEncoding:NSUTF8StringEncoding], xpathCtx);
    if (NULL == xpathObj) {
        xmlXPathFreeContext(xpathCtx);
        return NO;
    }

    // Update
    xmlNodeSetPtr nodes = xpathObj->nodesetval;
    int size, i;
    size = (nodes) ? nodes->nodeNr : 0;
    if (size > 0 && size != [nodeValue count]) {
        return NO;
    }
    /*
     * NOTE: the nodes are processed in reverse order, i.e. reverse document
     *       order because xmlNodeSetContent can actually free up descendant
     *       of the node and such nodes may have been selected too ! Handling
     *       in reverse order ensure that descendant are accessed first, before
     *       they get removed. Mixing XPath and modifications on a tree must be
     *       done carefully !
     */
    for(i = size - 1; i >= 0; i--) {
        assert(nodes->nodeTab[i]);

        xmlNodeSetContent(nodes->nodeTab[i], (xmlChar *)[nodeValue[i] cStringUsingEncoding:NSUTF8StringEncoding]);
        /*
         * All the elements returned by an XPath query are pointers to
         * elements from the tree *except* namespace nodes where the XPath
         * semantic is different from the implementation in libxml2 tree.
         * As a result when a returned node set is freed when
         * xmlXPathFreeObject() is called, that routine must check the
         * element type. But node from the returned set may have been removed
         * by xmlNodeSetContent() resulting in access to freed data.
         * This can be exercised by running
         *       valgrind xpath2 test3.xml '//discarded' discarded
         * There is 2 ways around it:
         *   - make a copy of the pointers to the nodes from the result set
         *     then call xmlXPathFreeObject() and then modify the nodes
         * or
         *   - remove the reference to the modified nodes from the node set
         *     as they are processed, if they are not namespace nodes.
         */
        if (nodes->nodeTab[i]->type != XML_NAMESPACE_DECL)
            nodes->nodeTab[i] = NULL;
    }

    xmlXPathFreeContext(xpathCtx);

    return YES;
}

Ignoring encoding:

xmlDocPtr doc = xmlReadMemory([data bytes], (int)[data length], "", nil, XML_PARSE_PEDANTIC);

Passing nil instead of the encoding in. . . .

ARC Error while using RaptureXML

When am trying to parse the remote XML file and get the images from it and view it as UIImageView. When i tried to call my remote XML file i got a warning and two errors as below,

'elementFromURL:' is deprecated
"_OBJC_CLASS_$_RXMLElement", referenced from:objc-class-ref in MyViewController.o ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation)
clang: error: linker command failed with exit code 1 (use -v to see invocation)

multiple methods named 'tag' found in mismatched result

I am getting "Multiple methods named 'tag' found with mismatched result, parameter type or attributes" error in Xcode.

I am using tag property from IB and passing this in an IBAction using:

  • (IBAction)buttonsTapped:(id)sender which of course essentially's UIView's property:
    @Property(nonatomic) NSInteger tag; // default is 0

and this is probably getting confused with RXMLElement's own tag property:
@Property (nonatomic, readonly) NSString *tag;

XPath not fetching nodes?

Hey,

Nice work! It's proven to be a nice alternative to some of the other xml readers out there.

I'm having an issue with RaptureXML not parsing XPath selectors correctly on my XML. This issue doesn't occur when manually traversing with child and children selectors. My issue is the exact same as the one here: http://stackoverflow.com/questions/14331087/xpath-with-rapturexml-not-matching-nodes

I think the issue might have something to do with namespaces but I'm not sure how to fix that.

Any suggestions?

Thanks!

RXMElement isEqualToString intValue....

When I try to use some method with RXMLElement I have this error : [RXMLElement isEqualToString:]: unrecognized selector sent to instance 0x746ef20]

[RXMLElement intValue:]: unrecognized selector sent to instance 0x746ef20]

How can I fix it??
Thanks in advance

Crash in (RXMLElement *)child:(NSString *)tag inNamespace:(NSString *)ns

If only some elements have namespace (I've replaced <> with _ here, since the editor will not try to interpret them):
ttl>15_/ttl_
atom:link href="http://feeds.bbci.co.uk/news/rss.xml" rel="self" type="application/rss+xml"/
item
title_Deadly Texas blast 'like tornado'/title_
and you are trying to use child:@"link" inNamespace:@"atom"

you will get crash at this piece of the code:

            if (cur->type == XML_ELEMENT_NODE && !xmlStrcmp(cur->name, tagC) && !xmlStrcmp(cur->ns->href, namespaceC)) {

Because cur->ns for the most elements from the example above will be nil, and dereferencing it is an error.

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.