Skip to content

Commit

Permalink
Merge pull request #13 from valeriyvan/comment
Browse files Browse the repository at this point in the history
Solves bug when first schema element is comment
  • Loading branch information
Daij-Djan authored Nov 5, 2016
2 parents 963c99b + 9a6d52d commit 0f989e9
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions framework/XMLUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,15 @@ + (NSString*)rootNodeNameFromURL:(NSURL*) url {
xmlTextReaderPtr reader = xmlReaderForFile( url.absoluteString.UTF8String,
NULL,
(XML_PARSE_NOBLANKS | XML_PARSE_NOCDATA | XML_PARSE_NOERROR | XML_PARSE_NOWARNING));
if(reader != nil) {
int ret = xmlTextReaderRead(reader);
if(ret == 1) {
obj = [NSString stringWithCString:(const char*)xmlTextReaderConstLocalName(reader)
encoding:NSUTF8StringEncoding];
}
xmlFreeTextReader(reader);

int status;
for ( ; (status = xmlTextReaderRead(reader)) && xmlTextReaderNodeType(reader) == XML_READER_TYPE_COMMENT; );

if (status) {
obj = [NSString stringWithCString:(char*)xmlTextReaderConstLocalName(reader) encoding:NSUTF8StringEncoding];
}

xmlFreeTextReader(reader);
return obj;
}

Expand Down Expand Up @@ -171,4 +172,4 @@ + (NSArray*) node:(NSXMLElement*) element descendantsWithName:(NSString*) name {
return children;
}

@end
@end

0 comments on commit 0f989e9

Please sign in to comment.