Giter VIP home page Giter VIP logo

tbxml's Introduction

What is TBXML

TBXML is a light-weight XML document parser written in Objective-C designed for use on Apple iPad, iPhone & iPod Touch devices (also Mac OSX compatible). TBXML aims to provide the fastest possible XML parsing whilst utilising the fewest resources. This requirement for absolute efficiency is achieved at the expense of XML validation and modification. It is not possible to modify and generate valid XML from a TBXML object and no validation is performed whatsoever whilst importing and parsing an XML document.

Performance

TBXML is incredibly fast! Check out this post for a good comparison of XML parsers. How To Chose The Best XML Parser for Your iPhone Project

Design Goals

  • XML files conforming to the W3C XML spec 1.0 should be passable
  • XML parsing should incur the fewest possible resources
  • XML parsing should be achieved in the shortest possible time
  • It shall be easy to write programs that utilise TBXML

What Now?

Have a play with the TBXML-Books sample project

View the "TBXML" wiki page to get find out how TBXML works. It contains many examples showing you how to use TBXML to parse your XML files. There are 2 complementary additions to extend the functionality of TBXML. These add the ability to automatically decompress files and perform asynchronous HTTP requests.

TBXML
TBXML+Compression
TBXML+HTTP


Love the project? Wanna buy me a coffee? [![donation](http://www.paypal.com/en_US/i/btn/btn_donate_SM.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=9629667)

MIT License

Copyright 2012 71Squared All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

tbxml's People

Contributors

kristopherjohnson avatar ralphshao avatar yonitsafir 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  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

tbxml's Issues

Ethical Hacking: memcpy and strlen functions used on iOS platform marked as vulnerabilities

Greetings!
I create this issue to make a question about your plugin.

We got an hybrid app and we decided to use a plugin called iRoot for avoiding rooted devices to run our app, this was a
requirement by Ethical hacking testers. The customer is pretty interested in checking all kinds of vulnerabilities in order to
be mitigated. This time a report was made about that plugin because it uses some functions which are considered dangerous; Those are memcpy and strlen, located in this file:
https://github.com/mapsplugin/cordova-plugin-googlemaps/blob/master/src/ios/GoogleMaps/TBXML.m

The mapsplugin team recently tell us that TBXML.m belongs to this library so we would like to know if you could help us with our question: ¿Do you have control on those functions usage (memcpy and strlen)? because we been told that they could produce memory overleaks

Thanks.

iOS target does not build

I'm trying to build you master branch on my build server. Build fails since "ARC_ENABLED" flag is not set by default.
Please fix default settings of your projects

Either set
CLANG_ENABLE_OBJC_ARC = NO

Or set
GCC_PREPROCESSOR_DEFINITIONS = DEBUG=1 $(inherited) ARC_ENABLED

/Users/darthvader/.jenkins/jobs/TBXML/workspace/TBXML-Code/TBXML+HTTP.m:21:13: error: 'autorelease' is unavailable: not available in automatic reference counting mode
return [request autorelease];
^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObject.h:37:1: note: declaration has been explicitly marked unavailable here

  • (id)autorelease NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
    ^
    /Users/darthvader/.jenkins/jobs/TBXML/workspace/TBXML-Code/TBXML+HTTP.m:21:13: error: ARC forbids explicit message send of 'autorelease'
    return [request autorelease];
    ^ ~~~~~~~~~~~
    /Users/darthvader/.jenkins/jobs/TBXML/workspace/TBXML-Code/TBXML+HTTP.m:47:6: error: 'release' is unavailable: not available in automatic reference counting mode
    [params release];
    ^
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObject.h:36:1: note: declaration has been explicitly marked unavailable here
  • (oneway void)release NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
    ^
    /Users/darthvader/.jenkins/jobs/TBXML/workspace/TBXML-Code/TBXML+HTTP.m:47:6: error: ARC forbids explicit message send of 'release'
    [params release];
    ^ ~~~~~~~
    /Users/darthvader/.jenkins/jobs/TBXML/workspace/TBXML-Code/TBXML+HTTP.m:48:13: error: 'autorelease' is unavailable: not available in automatic reference counting mode
    return [request autorelease];
    ^
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObject.h:37:1: note: declaration has been explicitly marked unavailable here
  • (id)autorelease NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
    ^
    /Users/darthvader/.jenkins/jobs/TBXML/workspace/TBXML-Code/TBXML+HTTP.m:48:13: error: ARC forbids explicit message send of 'autorelease'
    return [request autorelease];
    ^ ~~~~~~~~~~~
    6 errors generated.

TBXML ARC Issue

I favor using ARC in all of the apps I develop but I'm having a lot of trouble getting TBXML to function with ARC. Will there be a future release build that is compatible with ARC without having to modify any of the classes? Thanks in advance.

Load xml file in a sub directory

In the method initWithXMLFile, in order to load the file the following code is used:
NSString * bundlePath = [[NSBundle bundleForClass:[self class]] pathForResource:aXMLFile ofType:aFileExtension];
I think this is not good. Because when aXMLFile is a file path with directory it won't load correctly. The best way to handle it is to use pathForResource in directory:
NSString *directory = [aXMLFile stringByDeletingLastPathComponent];
NSString *file = [aXMLFile lastPathComponent];

    NSString * bundlePath = [[NSBundle bundleForClass:[self class]] pathForResource:file ofType:aFileExtension inDirectory:directory];

Hope you can fix it in the next version :)

Accented characters problem since 7.1

I am under the impression that the parser does not work properly since 7.1
All accented characters are replaced by other characters. For instance é is always replaced by √©

Anybody else having the same problem?

tbxml 1.4 memory leak, when profile the code.

Hello,

I just use the tbxml 1.4 for our iOS project, and thanks for your lib.

But always, I meet a memory leak issue point to the "textForElement" method.

  • (NSString_) textForElement:(TBXMLElement_)aXMLElement {
    if (nil == aXMLElement->text) return @"";
    return [NSString stringWithCString:&aXMLElement->text[0] encoding:NSUTF8StringEncoding];
    }

But I'm not sure it's the issue of the code or just the issue of the sdk or profile tool.

Please reply me, if you have the time.

Thanks,
A iOS developer Chris

Crash with nil error parameter

TBXML provides this method, which simply invokes another method with a nil error pointer:

- (id)initWithXMLData:(NSData*)aData {
    return [self initWithXMLData:aData error:nil];
}

There are other similar methods (-initWithXMLFile:, -initWithXMLFile:fileExtension:, etc.).

Unfortunately, if an error does occur, then the error handling code will try to dereference that nil pointer, and the app crashes. Some error-handling code does check for a null pointer before dereferencing it, but some does not.

Callers can work around this issue by calling the variant of the method that requires an error pointer. However, as-is these methods can easily lead to a crash, so I propose one of these actions be taken:

  • Remove the methods that don't require an error parameter. Require callers to pass an error parameter.
  • Change the methods that pass nil pointers such that they instead use a local error variable.
  • Change the error-handling code so that it always checks for a null error before trying to dereference it.

wrong result if text has >

example:
str =
@""
@""
@"<enclosure url='http://etch.s.dpool.sina.com.cn/nd/bbsdigi/myphoto_d/pic/2011/03/15/2023874167_733139c4cadbb9ffa223e80a02fa0127.jpg' type='image/jpeg' "
@"alt="" size='453*680'/>"
@"";

aData = [str dataUsingEncoding:NSUTF8StringEncoding];

// then parse nsdata aData, would got:

{
item = {
a = {
enclosure = {
alt = "453*680";
type = "image/jpeg";
url = "http://etch.s.dpool.sina.com.cn/nd/bbsdigi/myphoto_d/pic/2011/03/15/2023874167_733139c4cadbb9ffa223e80a02fa0127.jpg";
};
};
};
}

Reason:
text = 'test>>' contains >


data format to be parsed:
Screen Shot 2013-04-01 at 3 46 50 PM

TBXML parsing limited to XML files 'in app bundle'?

From what I can tell, this (very much improved in many ways) new version of TBXML assumes all XML files processed will be contained in the application bundle. That is absolutely a show-stopper for my requirements as I use XML files for all manner of communication between clients and server - most of which are never located "in the app bundle'.

I will implement my own work-around but it would be wonderful if this capability were incorporated into the official source code.

Thanks much!

XCode 4.4.1 Error Macro ARC

I would like to report an error in the use of macros to support ARC.

file: TBXML+HTTP.m:

/****************************************************************/

ifndef ARC_ENABLED <<<<<<< error, invert control

return [request autorelease];

else

return request;

endif

FIX:

ifdef ARC_ENABLED

return [request autorelease];

else

return request;

endif

/****************************************************************/

ifndef ARC_ENABLED <<<<<<< error, invert control

[params release];
return [request autorelease];

else

return request;

endif

FIX:

ifdef ARC_ENABLED

[params release];
return [request autorelease];

else

return request;

endif

/****************************************************************/

file: TBXML.m:

/****************************************************************/

ifndef ARC_ENABLED <<<<<<< error, invert control

[super dealloc];

endif

FIX:

ifdef ARC_ENABLED

[super dealloc];

endif

/****************************************************************/

value = [NSString stringWithString:@""]; <<<<<<< fix warning

FIX:

value = @"";
/****************************************************************/

TBXML Podspec is not working anymore after changes in the last 2 weeks

Hi Tom,

sorry not native english speaker…

TBXML Podspec is not working anymore, you changed the files 5 days before.

should be like this i think:

"source_files": [
"TBXML-Code/.{h,m}",
"TBXML-Headers/
.{h,m}"

but is now:

"source_files": "*.{h,m}“,

And currently the files are not found in Xcode Projects.

I hope this helps and you can fix the error soon.

Thank you and have a nice weekend.

Block callbacks: Parameter names are not specified

In the definition of all the blocks used in TBXML, the parameter names are not specified so there is no way to know what each parameter represents without digging into the TBXML.m file.

Example:
typedef void (^TBXMLIterateAttributeBlock)(TBXMLAttribute *, NSString *, NSString *);

Should be:
typedef void (^TBXMLIterateAttributeBlock)(TBXMLAttribute *attribute, NSString *name, NSString *value);

Using 'stringWithString:' with a literal is redundant

On line 360 I get the following compiler warning regarding NSString:

TBXML.m:360:25: Using 'stringWithString:' with a literal is redundant

Could you please fix this line from

value = [NSString stringWithString:@""];

to

value = @"";

Thanks!

Headers

Minor compared to, say, issue #23 (proper ARC detection) but it would be useful to have header files copied to a sensible location instead of the old "Public Headers Folder Path" default of /usr/local/include.

See knellr@c6d54f0 which uses the path "include/TBXML", allowing for TBXML to be included via #include <TBXML/TBXML.h>

TBXML Whitespace Handling

Hi folks, I recently wondered why TBXML strips all whitespace inside XML text, as far as I understand the XML specification, this is not allowed. Shall we prepare a patch that allows/forbids this globally or just remove it?

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.