Coder Social home page Coder Social logo

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

kissxml's Issues

No LICENSE file

Please add one, so I can be sure I've got everything just right. :)

Update documentation for ARC

I have an iOS 5.0 project and I am using ARC. Since the KissXML is non-ARC I have to tell the Compiler that these files are not ARC.

So what I had to do:

  1. Go to my target's "Build Phases" tab in Xcode
  2. Multi-select all KissXML files in the "Compile Sources" section
  3. Hit enter to bring up the "Compiler Flags" for the selected files
  4. Add the compiler flag -fno-objc-arc

Implement a new method to add value in a blank xml

Lets say I have a blank xml with elements, but now I need to add values to those elements for only specific elements. I know the element name. I can get the node and add the value to it, but there is no method to replace the node in the document

Swift 3 compatibility issues

Right now we use DDXML.swift to bridge between NSXML and DDXML because the preprocessor macros used for Obj-C don't work in Swift. The problem is that Apple removed the "NS" prefix in Swift 3, so the bridge no longer works. We could change the file to remove the prefix, but then it would break backwards compatibility.

Since using it with Swift already requires the SwiftNSXML subspec, perhaps we could leave that one as-is and make a separate Swift3XML subspec for Swift 3.

Fail to init from string - crashing

Hi,

DDXML failed to init from following fragment of XML. But NSXML handles well without any issue.

<presence xml:lang='en' from='[email protected]/XXX' to='[email protected]/XXX' version='1.0' xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:client'>
    <show>away</show>
    <status>iphone.imo.im</status>
    <nick xmlns='http://jabber.org/protocol/nick'>XX XX</nick>
    <c node='http://sleekxmpp.com/ver/1.2.0' ver='lTqgCk6RimJJS4ajzMjGMma0SWQ=' hash='sha-1' xmlns='http://jabber.org/protocol/caps'/>
    <x xmlns='vcard-temp:x:update'>
        <photo>xxxxxxxxxxxxxxxxxx</photo>
    </x>
</presence>

Test code:

NSString *str =
@"<presence xml:lang='en' from='[email protected]/XXX' to='[email protected]/XXX' version='1.0' xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:client'>"
    @"<show>away</show>"
    @"<status>iphone.imo.im</status>"
    @"<nick xmlns='http://jabber.org/protocol/nick'>XX XX</nick>"
    @"<c node='http://sleekxmpp.com/ver/1.2.0' ver='lTqgCk6RimJJS4ajzMjGMma0SWQ=' hash='sha-1' xmlns='http://jabber.org/protocol/caps'/>"
    @"<x xmlns='vcard-temp:x:update'>"
        @"<photo>xxxxxxxxxxxxxxxxxx</photo>"
    @"</x>"
@"</presence>";
NSError *error = nil;

NSXMLElement *nsBody = [[NSXMLElement alloc] initWithXMLString:str error:&error]; // pass
DDXMLElement *ddBody = [[DDXMLElement alloc] initWithXMLString:str error:&error]; // bad_access error here

It would be great if you could take a look. I'm also using XMPPFramework and this presence fragment causing crash.

Thank you!
-Thant

foud a broken link to old xmppframework (googlecode) in readme.markdown

The line "KissXML is a mature library used in thousands of products. It's also used in other libraries, such as XMPPFramework (an objective-c library for real-tiIe xml streaming). It's even used in hospital applications." in readme.markdown has broken link to the old xmppframework page.

DDXMLNode:XMLString can't handle unicode

Hi I find that DDXMLNode:XMLString can't handle unicode case, it will return string with unicode point &#x...

Just check this simple case,

DDXMLNode *node = [DDXMLNode attributeWithName:@"name" stringValue:@"我"];
NSLog(@"%@",[node XMLString]);

The output is "name="& # x6211;" // I have to add some space in between here otherwise my browser will convert to the corresponding unicode character

I have check the code but but have no idea how to fix it.

Manual Installation Instructions

Manual Installation Instructions

It would be nice to include some manual installation instructions, as it would appear to not be as straight forward as you might initially think (especially when trying to incorporate into a Swift framework)

Invalid expression

DDXMLElement *root = [document rootElement];
    DDXMLNode *defaultNameSpace = [root namespaceForPrefix:@""];
    defaultNameSpace.name = @"default";
    int index = 1;
    NSError *error;
    
    NSArray *spineNodes = [root nodesForXPath:@"//default:ncx/default:navMap" error:&error];

why?

libxml_module with tvos is unsupported

The required podspec changes to fix this were already made, but it appears that never made it to the public Cocoapods Specs repo with version 5.0.3.

additionally, the libxml and libxmlSimu modules are pointing to hard-coded paths. is $(SDK_ROOT) not available?

Create a DDXMLElement containing an NSArray

Hi everybody,

i'm trying to create a DDXMLElement which contains an nsarray of NSInteger, my code is:

DDXMLElement *type = [DDXMLElement elementWithName:@"type" stringValue:@"news_user_update_categories_subscriptions"];

DDXMLElement *channelId = [DDXMLElement elementWithName:@"news_channel_id" numberValue: [NSNumber numberWithInteger: _newsChannelId]];

DDXMLElement *subscriptionList = [DDXMLElement elementWithName:@"updated_categories_subscriptions_list" children:nil attributes: _categoriesSubscriptions];

when subscriptionList is going to be created, compiler return this error to me:

'NSInvalidArgumentException', reason: '-[__NSCFNumber _hasParent]: unrecognized selector sent to instance, 

i searched on internet but no results found, any help?

License missing

There's no license for KissXML on the GitHub site. Please add one. I can't use the software unless there's a license.

Can't build KissXML/libxml_module using cocoapods integration

I am trying to use KissXML's libxml_module subspec as a dependency in my cocoapod, but Xcode ends up not being able to build the module.

Below is the build error:

kiss-xml-build-error

That error would seem to indicate that my build settings are wrong, but they actually match the settings from KissXML/libxml_module's podspec.

What I don't understand is why the DDXML_LIBXML_MODULE_ENABLED macrodef ends up being 0 even though the libxml_module subspec's xcconfig settings explicitly set it to 1 as both part of the

When DDXML_LIBXML_MODULE_ENABLED is 0, in file KissXML/Core/DDXMLNode.h, the preprocessor conditionals end up trying to import libxml/tree.h (which does exist on my system in the proper places). But because CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES is NO, I get the non-modular import error.

KissXML/Core/DDXMLNode.h import conditionals
#if DDXML_LIBXML_MODULE_ENABLED
#if TARGET_OS_IOS && TARGET_OS_EMBEDDED
@import libxml;
#elif TARGET_IPHONE_SIMULATOR
@import libxmlSimu;
#elif TARGET_OS_MAC
@import libxmlMac;
#endif
#else
#import <libxml/tree.h>
#endif
KissXML/libxml_module subspec snippet
s.subspec 'libxml_module' do |ss|
    ss.dependency 'KissXML/Core'
    # ...
    ss.preserve_path = 'libxml/module.modulemap'
    ss.xcconfig     = { 'HEADER_SEARCH_PATHS' => '$(SDKROOT)/usr/include/libxml2 $(PODS_ROOT)/KissXML/libxml "$(PODS_ROOT)/../../../libxml"',
                        'CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES' => 'NO',
                        'OTHER_CFLAGS' => "$(inherited) -DDDXML_LIBXML_MODULE_ENABLED=1",
                        'OTHER_SWIFT_FLAGS' => "$(inherited) -DDDXML_LIBXML_MODULE_ENABLED"
                      }
  end

If in my cocoapod's podspec, I add to the same OTHER_CFLAGS settings to the xcconfig, I manage to get things trying to import the actual modules, but then the error is that it can't find module libxmlSimu.

Running pod lib lint KissXML.podspec also fails pretty badly. It reports errors similar issues as I describing above.

Thanks for taking the time to read this probably over-worded issue!

cc @chrisballinger @robbiehanson

Can't build KissXML/libxml_module in Xcode 8

Compiling a brand new project with the following Podfile seems to ignore the DDXML_LIBXML_MODULE_ENABLED flag and tries to run #import <libxml/tree.h> instead of the modules. This setup works as expected in Xcode 7. Presumably it has something to do with the libxml.modulemap, it the paths inside point to /Applications/Xcode.app, not Xcode-beta.app...

platform :ios, '9.0'

target 'KissXMLTest' do
  use_frameworks!
  pod 'KissXML/libxml_module'
end

image

Problem with DDXMLNode and NS_ASSUME_NONNULL_BEGIN

In DDXMLNode assumed to be not null while some parameters could be null and in swift I can not send nil as a value.
+ (id)namespaceWithName:(NSString *)name stringValue:(NSString *)stringValue;
It could be change to following
+ (id)namespaceWithName:(nullable NSString *)name stringValue:(NSString *)stringValue;

Subclassing DDXMLDocument, DDXMLElement, and DDXMLNode

I am looking to subclass each of the above classes for use with an SVG parser. I would like to replace the parsing mechanism in the SVGKit project (https://github.com/reklis/SVGKit) with KissXML. As stated in the Apple NSXML Documentation: "Because of the architecture and data model of NSXML, when it parses and processes a source of XML it cannot know about your subclass unless you override the class method replacementClassForClass: to return your custom class in place of an NSXML class. " Can you provide any insight on how I might subclass KissXML

Why this function return different result with the same parameter?

I called the function below in my project.However,the variable node is different with the same parameter name.For example,I set name as "name" ,the function below sometimes return "" and sometimes return "".So,What's the problem? And What should I do?

  • (id)initWithName:(NSString *)name
    {
    // Note: Make every guarantee that genericPtr is not null

    xmlNodePtr node = xmlNewNode(NULL, [name xmlChar]);
    if (node == NULL)
    {
    return nil;
    }

    return [self initWithElementPrimitive:node owner:nil];
    }

DDXMLDocument -validateAndReturnError: Not implemented

Hi there,

I'm using KissXML in my project, which has a very rigid structure and schema. I want to be able to automate testing against the schema, so I know my code doesn't generate bad XML.

NSXML provides a method on NSXMLDocument called -validateAndReturnError:, however DDXMLDocument doesn't implement this or any document validation with XML schemas at all.

If this could be implemented, it would greatly improve my test coverage and maybe have a few less people yelling at me to switch frameworks since this one doesn't support testing.

Cheers.

Kiss XML and armv7

Hi,i need some help,
I met this problem, i need use googleMap in my project,and I must do the following operation:
Replace the default value of Architectures with armv7.
In the Other Linker Flags section, add -ObjC. If these settings are not visible, change the filter in the Build Settings bar from Basic to All.
But if i do this,the KissXML don't work...
Some Error like this:
duplicate symbol OBJC_METACLASS$_DDXMLInvalidNode in:
/Users/zxguo/Library/Developer/Xcode/DerivedData/AvePoint.CRM.TimeLine.IPhone-drfocqfderkbqcgsikoffypeyhek/Build/Intermediates/CRMTimeLine.build/Debug-iphonesimulator/CRMTimeLine.build/Objects-normal/i386/DDXMLNode.o
/Users/zxguo/Library/Developer/Xcode/DerivedData/AvePoint.CRM.TimeLine.IPhone-drfocqfderkbqcgsikoffypeyhek/Build/Products/Debug-iphonesimulator/CRMTimeLineCore.framework/CRMTimeLineCore(DDXMLNode.o)
ld: 16 duplicate symbols for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I don't know how to do. Please help me.Thanks very much.

DDXMLNode attributeForName fails after ARC Conversion

The code below compel;lied and ran fine before converting to ARC and using the new KISSXML 5.0 libraries updated for ARC. I now get an error when compiling the ARC project at these lines:

            DDXMLNode *attrRecSeqNoName = [node attributeForName:@"recSeqNo"];

ERROR is:
Automatic Reference Counting Issue:
Receiver type 'DDXMLNode' for instance message does not declare a method with selector 'attributeForName:'

Hope you can help me.

CODE SNIPPET:

DDXMLDocument *doc = [[DDXMLDocument alloc] initWithData:xmlData options:0 error:nil];
NSArray *items = [doc nodesForXPath:@"//block/*" error:nil];

for (DDXMLElement *item in items) 
{

    for (int i = 0; i < [item childCount]; i++) //START LOOP
    {  
     DDXMLNode *node = [item childAtIndex:i];

        name = [node name];
        value = [node stringValue];

        if ([name isEqualToString:@"recordBnr"])
        {

            DDXMLNode *attrRecSeqNoName = [node attributeForName:@"recSeqNo"];
            NSString *attrRecSeqNo = [attrRecSeqNoName XMLString];
            DDXMLNode *attrLimitMaxName = [node attributeForName:@"limitMax"];
            NSString *attrLimitMax = [attrLimitMaxName stringValue];
            DDXMLNode *attrLimitMinName = [node attributeForName:@"limitMin"];
            NSString *attrLimitMin= [attrLimitMinName stringValue];

            NSLog(@"attrRecSeqNo = %@", attrRecSeqNo);
             NSLog(@"attrLimitMin = %@", attrLimitMin);
             NSLog(@"attrLimitMax = %@", attrLimitMax);
         }
    }

}

nodesForXPath fails if xml document has processing instructions

I have encountered an issue where XPath Queries will fail in KissXML when the XML contains processing instructions, but will work fine if the exact same XML does not contain any processing instructions.

As an example I have the following XML without processing instructions (demo1.xml):

<?xml version="1.0"?>
<tst:TstForm xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tst="http://schemas.somewhere.com/tst/1" xml:lang="en-US">
    <tst:TstDetails>
        <tst:Title>Labelling error on boxes</tst:Title>
        <tst:Description>Box labels</tst:Description>
    </tst:TstDetails>
</tst:TstForm>

I am parsing the XML and executing an XPath query as follows:

// Parse the DEMO XML - no processing instructions,
// so this will work
NSLog(@"**** About to parse %@ ****\n\n", xmlFilename);
NSString *XMLPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:xmlFilename];
NSData *XMLData   = [NSData dataWithContentsOfFile:XMLPath];

NSError *err=nil;
NSURL *furl = [NSURL fileURLWithPath:XMLPath];
if (!furl) {
    NSLog(@"Can't create an URL from file: %@.", XMLPath);
    return;
}
xmlViewDoc = [[DDXMLDocument alloc] initWithData:XMLData
                                              options:0
                                                error:&err];

// Prove that the XML was parsed correctly...
NSLog(@"Root node'%@' found\n\n", xmlViewDoc.rootElement.name);
NSLog(@"About to iterate through elements 2 levels down from the root node...");
NSArray *nodes = xmlViewDoc.rootElement.children;
for (DDXMLElement *node in nodes) {
    NSArray *childNodes = node.children;
    for (DDXMLElement *childNode in childNodes) {
        NSLog(@" XPath: %@", childNode.XPath);
    }
}
NSLog(@"Root node elements END\n\n");

// Show that the namespaces are parsed correctly
NSLog(@"Root node contains the following namespaces...");
nodes = xmlViewDoc.rootElement.namespaces;
for (DDXMLElement *node in nodes) {
    NSLog(@" Found NS: '%@' = '%@'", node.name, node.stringValue);
}
NSLog(@"Namespaces END\n\n");

// Now execute an XPath query using the namespace
NSString *xPathQuery = @"/tst:TstForm/tst:TstDetails";
NSLog(@"Based on the above namespace and the XML structure, we should be able to execite the following XPath query:\n %@", xPathQuery);
NSLog(@"The XPath query should return two elements (Title & Description)...");
nodes = [xmlViewDoc.rootElement nodesForXPath:xPathQuery error:nil];
for (DDXMLElement *node in nodes) {
    NSLog(@" XPath: %@", node.XPath);
}
NSLog(@"XPathQuery END\n\n");

This code provides the following log output as expected:

2012-09-03 13:04:25.662 NDPad[37359:c07] **** About to parse demo1.xml ****

2012-09-03 13:04:25.690 NDPad[37359:c07] Root node'tst:TstForm' found

2012-09-03 13:04:25.690 NDPad[37359:c07] About to iterate through elements 2 levels down from the root node...
2012-09-03 13:04:25.691 NDPad[37359:c07]  XPath: /TstForm[1]/TstDetails[1]/Title[1]
2012-09-03 13:04:25.691 NDPad[37359:c07]  XPath: /TstForm[1]/TstDetails[1]/Description[1]
2012-09-03 13:04:25.691 NDPad[37359:c07] Root node elements END

2012-09-03 13:04:25.691 NDPad[37359:c07] Root node contains the following namespaces...
2012-09-03 13:04:25.692 NDPad[37359:c07]  Found NS: 'xsi' = 'http://www.w3.org/2001/XMLSchema-instance'
2012-09-03 13:04:25.692 NDPad[37359:c07]  Found NS: 'tst' = 'http://schemas.somewhere.com/tst/1'
2012-09-03 13:04:25.692 NDPad[37359:c07] Namespaces END

2012-09-03 13:04:25.692 NDPad[37359:c07] Based on the above namespace and the XML structure, we should be able to execite the following XPath query:
 /tst:TstForm/tst:TstDetails
2012-09-03 13:04:25.692 NDPad[37359:c07] The XPath query should return two elements (Title & Description)...
2012-09-03 13:04:25.693 NDPad[37359:c07]  XPath: /TstForm[1]/TstDetails[1]
2012-09-03 13:04:25.693 NDPad[37359:c07] XPathQuery END

However, if I then use the following XML which contains a single processing instruction (demo1-5.xml):

<?xml version="1.0"?>
<?tst-example-instruction?>
<tst:TstForm xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tst="http://schemas.somewhere.com/tst/1" xml:lang="en-US">
    <tst:TstDetails>
        <tst:Title>Labelling error on boxes</tst:Title>
        <tst:Description>Box labels</tst:Description>
    </tst:TstDetails>
</tst:TstForm>

The same code will fail, and only provide the following output:

2012-09-03 13:04:25.693 NDPad[37359:c07] **** About to parse demo1-5.xml ****

2012-09-03 13:04:25.756 NDPad[37359:c07] Root node'tst:TstForm' found

2012-09-03 13:04:25.756 NDPad[37359:c07] About to iterate through elements 2 levels down from the root node...
2012-09-03 13:04:25.756 NDPad[37359:c07]  XPath: /TstForm[1]/TstDetails[1]/Title[1]
2012-09-03 13:04:25.756 NDPad[37359:c07]  XPath: /TstForm[1]/TstDetails[1]/Description[1]
2012-09-03 13:04:25.756 NDPad[37359:c07] Root node elements END

2012-09-03 13:04:25.757 NDPad[37359:c07] Root node contains the following namespaces...
2012-09-03 13:04:25.757 NDPad[37359:c07]  Found NS: 'xsi' = 'http://www.w3.org/2001/XMLSchema-instance'
2012-09-03 13:04:25.757 NDPad[37359:c07]  Found NS: 'tst' = 'http://schemas.somewhere.com/tst/1'
2012-09-03 13:04:25.757 NDPad[37359:c07] Namespaces END

2012-09-03 13:04:25.757 NDPad[37359:c07] Based on the above namespace and the XML structure, we should be able to execite the following XPath query:
 /tst:TstForm/tst:TstDetails
2012-09-03 13:04:25.758 NDPad[37359:c07] The XPath query should return two elements (Title & Description)...
2012-09-03 13:04:25.758 NDPad[37359:c07] XPathQuery END

I can't see what would be wrong with this XML that would cause the XPath queries to fail, especially when iterating through the DOM shows that it parsed correctly.

Thanks,
Paul

Module 'KissXML' not found.

Hi,

I have this issue when I try to import an internal module (of my own) which includes XMPPFramework and all using CocoaPods.

The exact issue is

XMPPSASLAuthentication.h line 2
"Module KissXML not found"

To explain it more precisely, here is my Pod structure:

  • Conversation framework, which uses XMPPFramework, declared in a private Pod repo and exposing this podspec:
Pod::Spec.new do |s|
 (...)
  s.dependency 'XMPPFramework'
end

Here no version is set as I doesn't want to use the ProcessOne fork because I need the latest version of Lumberjack in the XMPP Core. I will precise the original repository in my Main application Podfile, like detailed below.

  • Main app with a Podfile looking like this:
source 'https://github.com/CocoaPods/Specs.git'
source 'ssh://[email protected]/private-specs-registry.git'

platform :ios, '8.0'
use_frameworks!

workspace 'MainApp'

# MainAppPods
def main_app_pods

    # Here I precise that I want to use the original repo of XMPPFramework (needed because I don't want to use the ProcessOne fork)
    pod 'XMPPFramework', git: 'https://github.com/robbiehanson/XMPPFramework'

    # Internal Conversation framework which uses XMPPFramework
    pod 'Conversation', '0.0.1'

end

target 'Messenger' do
    project 'Messenger'

    main_app_pods
end

pre_install do |installer|
    # workaround for https://github.com/CocoaPods/CocoaPods/issues/3289
    def installer.verify_no_static_framework_transitive_dependencies; end
end

post_install do |installer_representation|
    installer_representation.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            # To avoid "Undefined symbols for architecture" at build time.
            config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
            # XMPPFramework is not bitcode compatible... We need to deactive that.
            # PR still open (2016/02/02) https://github.com/robbiehanson/XMPPFramework/issues/562
            config.build_settings['ENABLE_BITCODE'] = 'NO'
            config.build_settings['CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES'] = 'YES'
        end
    end

    installer_representation.pods_project.build_configuration_list.build_configurations.each do |configuration|
      # To avoid "Undefined symbols for architecture" at build time for the Pods project.
      configuration.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
      configuration.build_settings['CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES'] = 'YES'
    end
end

In my main application

First, when I do a pod install I have some warnings (I don't know if it's relevant for my issue):

Pod installation complete! There are 14 dependencies from the Podfile and 29 total pods installed.

[!] Can't merge user_target_xcconfig for pod targets: ["libxml_module", "Core", "Providers"]. Boolean build setting CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES has different values.

[!] Can't merge user_target_xcconfig for pod targets: ["libxml_module", "Core", "Providers"]. Boolean build setting CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES has different values.

And then when I try to build my main app I got this following error:

XMPPSASLAuthentication.h (line 2)
- Module KissXML not found

If you find some time to unlock me it will be really great.

Allow easier turn on of #define NS* declarations

Currently you must modified the DDXML.h header to turn on the #define NS* declarations.

Instead of:

#if TARGET_OS_IPHONE && 0 // Disabled by default

Do:

#ifndef DDXML_NS_DECLARATIONS_ENABLED
#define DDXML_NS_DECLARATIONS_ENABLED 0 // Disabled by default
#endif

#if DDXML_NS_DECLARATIONS_ENABLED

Which would allow "turn on" without modifying the headers. This is important so KissXML can be easily updated and not "patched" over and over to turn it on.

Error when using insertChild method

Hi,
I have a problem when I tried to use the insertChild method. I keep getting the same error.
Here's the code I used (I took it from an online tutorial) :

DDXMLDocument *document = [[DDXMLDocument alloc] initWithXMLString:@"" options:0 error:nil];
DDXMLElement *root = [document rootElement];
[root insertChild:[DDXMLNode elementWithName:@"address" stringValue:@"Some Address"] atIndex:0];

The error showing in the log is :

2012-01-29 11:20:50.401 MathTutor[900:f803] -[__NSCFConstantString xmlChar]: unrecognized selector sent to instance 0x4a644
2012-01-29 11:20:50.614 MathTutor[900:f803] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFConstantString xmlChar]: unrecognized selector sent to instance 0x4a644'
*** First throw call stack:
(0x1725052 0x18b6d0a 0x1726ced 0x168bf00 0x168bce2 0x2f790 0x326bd 0x3a8ec 0xee61 0x3917 0x2fd2 0x25964e 0x1b9a73 0x1b9ce2 0x1b9ea8 0x1c0d9a 0x2a5e 0x1919d6 0x1928a6 0x1a1743 0x1a21f8 0x195aa9 0x160ffa9 0x16f91c5 0x165e022 0x165c90a 0x165bdb4 0x165bccb 0x1922a7 0x193a9b 0x2788 0x26e5)

I'm using XCode 4.2.1 with iOS SDK 5.0 (I use the latest KissXML which support ARC).
I'm really greatfull if you can help me resolve this issue because I'm new in iOS Programming. Thanks.

Compile Error

I'm feeling stupid, but I'm getting a build error. <libxml/tree.h> is not being found. I've got the header search path including /usr/include/libxml2 (recursive), I've added the libxml2.dylib library.

Any ideas? Sometimes the compile errors with Xcode are stupidly baffling, and I feel like a complete idiot. Anyone with a clue-bat is welcome to whack me upside the head!

Edit: Oh. The errors are happening in DDXMLNode.h and NSString+DDXML.h.

isEqual: behaves differently to Apple NSXMLNode/Element

This should be noted in the documentation or code comments. KissXML "isEqual:" compares class and then object pointer only for the underlying libxml node.

Apple's "isEqual:" says:

"By default NSXMLNode implements the NSObject isEqual: method to perform a deep comparison: two NSXMLNode objects are not considered equal unless they have the same name, same child nodes, same attributes, and so on. The comparison looks at the node and its children, but does not include the node’s parent. If you want a different standard of comparison, override isEqual:."

Things that would be equal under Apple fail under KissXML. I am not asking for it to be changed, but just recommending that it be noted in the code comments are somewhere convenient so that users of KissXML can plan around the difference.

I noted this by creating an XMLString of a node and then creating another node using that XMLString and comparing them with "isEqual:". Creating new XMLString from both show that they are exactly the same.

how to use xpath to get xml nodes(the xml includes namespace)

When I use xpath to get xml nodes as below, it returns 0 objects. I know the reason is xml's namespace. But I don't know how to solve this problem with KissXML.

ps: I use "[]" to replace "<>" because of the github editor can't display them rightly.

XML:
[?xml version="1.0" encoding="utf-8"?]
[soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"]
[soap:Body]
[HelloTestResponse xmlns="http://tempuri.org/"]
[HelloTestResult>string</HelloTestResult]
[/HelloTestResponse]
[/soap:Body]
[/soap:Envelope]

KissXML method:
DDXMLDocument *doc = [[DDXMLDocument alloc] initWithXMLString:theXML options:0 error:nil];
NSArray *nodes = [doc nodesForXPath:@"//HelloTestResponse" error:nil];

The nodes' count is always 0;

nodesForXPath fails if xml document has DOCTYPE

If you add a DOCTYPE to the xml in testNodesForXPath you'll see that test 6 fails. For instance I added the following.

[xmlStr appendString:@"<?xml version=\"1.0\"?>"];
[xmlStr appendString:@"<!DOCTYPE AirSync PUBLIC \"-//AIRSYNC//DTD AirSync//EN\" \"http://www.microsoft.com/\">"];
[xmlStr appendString:@"<menu xmlns:a=\"tap\">"];

It fails because in DDXMLNode nodesForXPath:error: because the line

xmlNodePtr rootNode = (doc)->children;

returns the a node with the name AirSync instead of the real root node. I changed this to

    xmlNodePtr rootNode = xmlDocGetRootElement(doc);

Also if the xml uses a default namespace such as

<Sync xmlns="http://synce.org/formats/airsync_wm5/airsync">

and you try to add a prefixed namespace to the root node such as

<Sync xmlns=as="http://synce.org/formats/airsync_wm5/airsync">

it will fail. This is because a non-prefixed namespace is added in the line

    xmlXPathRegisterNs(xpathCtx, ns->prefix, ns->href);

I changed this to

            if (ns->prefix && ns->prefix[0] != '\0') {
                xmlXPathRegisterNs(xpathCtx, ns->prefix, ns->href);
            }

and now it works. In summary I changed

    xpathCtx = xmlXPathNewContext(doc);
    xpathCtx->node = (xmlNodePtr)genericPtr;

    xmlNodePtr rootNode = (doc)->children;
    if(rootNode != NULL)
    {
        xmlNsPtr ns = rootNode->nsDef;
        while(ns != NULL)
        {
            xmlXPathRegisterNs(xpathCtx, ns->prefix, ns->href);

            ns = ns->next;
        }
    }

to

    xpathCtx = xmlXPathNewContext(doc);
    xpathCtx->node = (xmlNodePtr)genericPtr;

    xmlNodePtr rootNode = xmlDocGetRootElement(doc);
    if(rootNode != NULL)
    {
        xmlNsPtr ns = rootNode->nsDef;
        while(ns != NULL)
        {
            if (ns->prefix && ns->prefix[0] != '\0') {
                xmlXPathRegisterNs(xpathCtx, ns->prefix, ns->href);
            }

            ns = ns->next;
        }
    }

Error handlers not set correctly

Per the libxml2 documentation for xmlSetStructuredErrorFunc:

Function to reset the handler and the error context for out of context structured error messages. This simply means that @handler will be called for subsequent error messages while not parsing nor validating. And @ctx will be passed as first argument to @handler For multi-threaded applications, this must be set separately for each thread.

Unfortunately, KissXML only attempts to set these functions as part of +initialize. Instead, they need to be installed each time a call is made into the library that could fail.

This is probably a fairly large issue, and potentially unfixable at the library level; having a public class method to install the error handlers would probably be sufficient. This way, code intentionally using KissXML off the main thread could specifically initialize the error handlers.

Symbol not found: _objc_retain

I'm trying to use KissXML in a non-arc project targeted por ipad (4.2). I already add the -f-objc-arc to KissXML files and it is working fine for ios 5.

The error I'm getting appear in this line of code

DDXMLDocument *xmlDocument = [[DDXMLDocument alloc] initWithXMLString:[self xmlDefaultString]
options:DDXMLDocumentKind
error:&error];

It is actually the first time I create a xml document. The error is the following

dyld: lazy symbol binding failed: Symbol not found: _objc_retain
Referenced from: /Users/tluisrs/Library/Application Support/iPhone Simulator/4.3.2/Applications/8692134A-C2CA-4AA5-95D6-FA90962C6D2B/ValeHub.app/ValeHub
Expected in: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk/System/Library/Frameworks/Foundation.framework/Foundation

5.0.3 installed via pod but I cant use it in my swift app as it wont compile

5.0.3 installed via pod but I cant use it in my swift app as it wont compile

main.swift:10:8: Could not build Objective-C module 'KissXML'

then for KissXML

DDXMLNode.h:12:9: Include of non-modular header inside framework module 'KissXML.DDXMLNode'
NSString+DDXML.h:12:9: Include of non-modular header inside framework module 'KissXML.NSString_DDXML'

How to add libxml2.dylib in xcode 7

I am trying to add xmpp framework in my ios app.After adding it's showing

libxml/tree.h file not found

after some googling I found that need to add libxml2.dylib in Build Phases -> Link Binary With Libraries.But I am not finding this file. but i found .tbd file.I try to add .tbd file and set Header search path as $(SDKROOT)/usr/include/libxml2 but it still showing same error.

Not build after xcode 7.3,xcode 8

i cant build i've tried many things

i'm getting this build errors

Undefined symbols for architecture arm64:
"_xmlStrdup", referenced from:
-[DDXMLNamespaceNode setName:] in libKissXML.a(DDXMLNode.o)
"_xmlDocSetRootElement", referenced from:
-[DDXMLNode nodesForXPath:error:] in libKissXML.a(DDXMLNode.o)
"_xmlXPathFreeContext", referenced from:
-[DDXMLNode nodesForXPath:error:] in libKissXML.a(DDXMLNode.o)

nodesForXPath:error: logs error, but error is nil

The console logs XPath error : Undefined namespace prefix and XPath error : Invalid expression, which is correct, but the error points to nil.

With a breakpoint at

    if (xpathObj == NULL) {
        if (error) *error = [[self class] lastError];
        result = nil;
    }

i see that lastError = nil

DDXMLElement elementsForLocalName:URI variable shadowing

In the ARC branch, DDXMLElement elementsForLocalName:URI, the second declaration of the prefix variable within the else block shadows the first declaration.

Benign, but triggers a warning message when the 'Hidden Local Variables' warning is turned on.

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.