Tag: nsxmlparser

How do I parse a basic XML file with NSXMLParser?

I am trying to figure out NSXMLParser for my iPhone app and while I generally understand how it works, I am still a little confused about how to extract the values I need. The XML result that I am parsing is very basic. it is like so: <start> <status>300</status> <record> <title>The Title</title> <content>Some content</content> </record> […]

How to encode a string with special characters that will be POSTed to a URL? Objective-C

Currently I have a string that I want to POST to a URL. It works perfectly fine except when it encounters special characters like “&”, and “?”. It will not POST any data that comes after that. For example, if I have a string “I am something & something?”, it will only POST “I am […]

How to set a delegate in a different class

I’m working with NSXMLParser that parses a xml document. You have to set the delegate which we would be called every time the parser finds an element. The examples I’ve looked at all set the delegate to be the same class that’s createing: NSXMLParser *parser = [[NSXMLParser alloc] initWithContentsOfURL:filename]; [parser setDelegate: self]; Other examples set […]

Is NSXMLParser's parse method asynchronous

Is NSXMLParser’s parse method asynchronous? in other words if i have an NSXMLParse object and I call [someParseObject parse] from the main thread, will it block the main thread while it does its thing?

How to resolve an internally-declared XML entity reference using NSXMLParser

I have an XML file that uses internally-declared entities. For example: <?xml version=”1.0″ encoding=”UTF-8″?> … <!ENTITY my_symbol “my symbol value”> … <my_element> <my_next_element>foo&my_symbol;bar</my_next_element> </my_element> … Using the NSXMLParser class, how am I able to resolve the my_symbol entity reference? From experimentation, the parser:foundInternalEntityDeclarationWithName:value: delegate method will be called for the my_symbol entity declaration, with value […]

Simple and concise desktop Cocoa NSXMLParser example?

I would like to look through the elements of a file and when one specific element comes out, output the contents in between the tag. I tried to follow the example in the Mac Dev entitled Event Driven XML Programming, but it just doesn’t finish very clearly. It says to make sure I code the […]

NSXMLParser can not get the content of elements correctly

i have the following XMLParser but when i try to run it, it doesn’t work properly. – (void) parser:(NSXMLParser *)parser didStartElement:(NSString *)elementname namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict { if ([elementname isEqualToString:@”results”]) { currentJob = [SearchResult alloc]; } } – (void) parser:(NSXMLParser *)parser didEndElement:(NSString *)elementname namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName { if ([elementname isEqualToString:@”jobTitle”]) { currentJob.jobTitle […]

Pesky new lines and whitespace in XML reader class

I’m using a class written by a blogger (http://troybrant.net/blog/) that takes an XML string and spits out a NSDictionary. It’s beautiful…works perfectly, except I end up with a weird configuration of newlines and white space at the beginning of many element values. I haven’t been able to figure out why. I’m posting the class here […]

NSXMLParser chokes on ampersand &

I’m parsing some HTML with NSXMLParser and it hits a parser error anytime it encounters an ampersand. I could filter out ampersands before I parse it, but I’d rather parse everything that’s there. It’s giving me error 68, NSXMLParserNAMERequiredError: Name is required. My best guess is that it’s a character set issue. I’m a little […]

Using NSXMLParser initWithStream: no parser delegate methods received

The basic problem I’m working on is using the NSStream classes to parse incoming incremental XML data. The data is never a complete XML Document, but I want to receive and process it in incremental chunks based off how much ever the socket can read. Looking at the documentation for NSXMLParser, it seems like the […]