IntroductionTouchXML is a lightweight replacement for Cocoa's NSXML cluster of classes. It is based on the commonly available Open Source libxml2 library. LicenseTouchXML is released under the MIT license. GoalsThe goal is to create a lightweight NSXML style XML api that can used in environments without NSXML (e.g. iPhone). - XML read only. The aim is to make a lite API for reading XML. I'm assuming most applications will only need to read XML and wont need to generate it (AJAX applications tend to receive XML data but transmit data via URL or HTTP form-encoding). Please let me know if your application needs XML write support.
- Lightweight. Rarely used NSXML functionality should not be implemented.
Currently implemented- XML parsing from NSString and NSData.
- Support for Documents, Elements, Attributes. Most NSXMLNode "navigation" methods are implemented (parent, nextSibling, children, etc).
- Basic xpath support.
- Unit Tests
RoadmapShort Term- Improved xpath functionality (make 1:1 equivalent with NSXMLNode).
- More Unit Tests
- Robust error handling (use xmlError.h)
- Support for any NSDocument option flags that make sense.
- 1:1 equivalency with NSXMLNode apis for naviation (I think we are equivalent, just need unit tests to prove it).
Medium Term- Namespace Support
- xslt support
Long Term/Never- XML output/writing
- xquery
- XML tidy (this includes HTML importing)
|
Thanks for these additions, I hope they can help me (Still having some problems with parsing my HTML Data, will have to check some code over and over again I suppose. NSXML was working fine.)
I noticed a problem when tidying using CXMLDocumentTidyHTML, since the enum has not been defined properly, it should be something like:
enum { CXMLDocumentTidyHTML = (1 << 0), // Based on NSXMLDocumentTidyHTML CXMLDocumentTidyXML = (1 << 1), // Based on NSXMLDocumentTidyXML };At the moment, CXMLDocumentTidyHTML equals 0 so it's not possible to compare bitwise.
Oh, before I forget to mention: I have changed the CTidy instance methods to be class methods, just because it's not needed to have an instance of the class.
Will someone give me some help for including the tidy source code?
I have downloaded the tidy04aug00.tar and expanded it. This is what I get:
/Users/q231950/Downloads/tidy4aug00/release-notes.html /Users/q231950/Downloads/tidy4aug00/pprint.c /Users/q231950/Downloads/tidy4aug00/man_page.txt /Users/q231950/Downloads/tidy4aug00/Makefile /Users/q231950/Downloads/tidy4aug00/parser.c /Users/q231950/Downloads/tidy4aug00/Overview.html /Users/q231950/Downloads/tidy4aug00/tidy.gif /Users/q231950/Downloads/tidy4aug00/tidy.c /Users/q231950/Downloads/tidy4aug00/grid.gif /Users/q231950/Downloads/tidy4aug00/entities.c /Users/q231950/Downloads/tidy4aug00/platform.h /Users/q231950/Downloads/tidy4aug00/pending.html /Users/q231950/Downloads/tidy4aug00/lexer.c /Users/q231950/Downloads/tidy4aug00/attrs.c /Users/q231950/Downloads/tidy4aug00/tags.c /Users/q231950/Downloads/tidy4aug00/tab2space.c /Users/q231950/Downloads/tidy4aug00/istack.c /Users/q231950/Downloads/tidy4aug00/clean.c /Users/q231950/Downloads/tidy4aug00/config.c /Users/q231950/Downloads/tidy4aug00/localize.c /Users/q231950/Downloads/tidy4aug00/html.h
How to proceed?
Thanks in advance & have a nice day, Martin Pham
Then you already get more out of the .tar file than what I got, I was stuck in a loop of archive files.
The tidylib files are actually in the SVN checkout and you have to add the files from the tidylib/src and tidylib/include folder to your project. Then it should work fine.
Thanks Joost!
The CVS checkout is obligatory since the repository's content is completely different compared to the files in the tidy04aug00.tar.
I don't know if this is relevant or not, but NSXML ignores open-ended tags, like <a name="">, while CXML doesn't. This was the main difference I noticed when parsing using XPath. The other was that parsing a NSString with non-Latin characters converts them to something else, i.e. there is some encoding mixup in the pipeline, which is a real bummer for me. NSXML doesn't have this problem.
I've created TouchCode? Dev Google Group. This is now the preferred forum for TouchCode? related development questions: http://groups.google.com/group/touchcode-dev
Is it me or is TouchXML.h file missing from the SVN Checkout?
Yeah, maybe this is why importing CXMLDocument.h results in 254 build errors about missing files and constants.
Just make one with this:
sorry:
Where exactly do we add those 2 configuration lines?
Project Info -> Build Tab -> Set "Other linker flags" to -lxml2 and Set "Header Search Paths" to /usr/include/libxml2
are there any examples? I can't find any decent docs or examples...
You need to add the Header Search Path in both Edit Project Settings and Edit Active Target "YourApp?", by the way.
First of all, thank you very much for doing this. It looks great :)
Do anyone know of any examples ?
What is inOption ?
Great stuff.
Bergetun: The api mirrors NSXML pretty closely. Look at Apple's (non-iphone) documentation on NSXML for example of how to use this. You'll just need to replace the NS with C in the classnames.
A good starting point in the 'Core Library' docs would be "Introduction to Tree-Based XML Programming Guide for Cocoa". Just search for it - but make sure your search query is set to 'Full text' and not 'API'.
By the way, there's a great tutorial for TouchXML here: http://dblog.com.au/general/iphone-sdk-tutorial-building-an-advanced-rss-reader-using-touchxml-part-1/
I've created TouchCode? Dev Google Group. This is now the preferred forum for TouchCode? related development questions: http://groups.google.com/group/touchcode-dev
I got 32 errors following the described method.
All errors are coming in CTidy.h & CTidy.m file.
1) tidy.h: no such file or directory. 2) buffio.h: no such file or directory. 3) 'TidyDoc?' undeclared (first use in this function) .... .... ....
It seems you now also need to add the files from TouchXML/Externals/tidy/include, but I still got 14 errors during build, a lot of these...
Those would just be the headers. If you add the TouchXML/Externals/tidy/src, it should work.
I'm getting the same errors as sagarbeec
"I got 32 errors following the described method.
All errors are coming in CTidy.h & CTidy.m file.
1) tidy.h: no such file or directory. 2) buffio.h: no such file or directory. 3) 'TidyDoc??' undeclared (first use in this function) .... .... ...."
I did this:
Those would just be the headers. If you add the TouchXML/Externals/tidy/src, it should work.
And got 3123 erros :-)
Hi All,
i solve the problem with this: adding: "TouchXML/Externals/tidy/include" AND "TouchXML/Externals/tidy/src"
this works for me at the moment
I managed to compile, my problem is that parsing an HTML page gives several errors in console like:
Entity: line 8: parser error : Opening and ending tag mismatch: INPUT line 7 and FORM </FORM>
The very same html page was parsed correctly by equivalent NSXMLDocument and NSXMLElement...
...the result is that an xpath query gives no results using CXMLDocument while gives expected results using NSXMLDocument
Can someone please help me understand something?
Is it possible to compile the touchxml code as a library to use in a project instead of putting all the source files in a common directory for every project this would yield a neater code structure.
There is a nuke file that contains the following lines of code. I dont understand how this is used but i take it these are the steps to follow ?
;; ;; Nukefile for TouchXML ;; ;; Commands: ;; nuke - builds TouchXML as a framework ;; nuke test - runs the unit tests in the NuTests? directory ;; nuke install - installs TouchXML in /Library/Frameworks ;; nuke clean - removes build artifacts ;; nuke clobber - removes build artifacts and TouchXML.framework ;; ;; The "nuke" build tool is installed with Nu (http://programming.nu) ;;
Thanks in advance.
You rock.
This will be super helpful. I can't believe this isn't part of the framework...
Thank you so much! I cannot believe they didn't include web services core...
how about some sample code for win32 developers?
@nicktulip The code is based on a subset of NSXMLDocument, You can see apple's documentation for NSXMLDocument here: http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSXMLDocument_Class/Reference/Reference.html
There's a bit of info here too:
http://code.google.com/p/touchcode/wiki/TouchXMLImplementation
It's very useful, thanks.
Where can i download the TouchXML framework?
you can check it out using: svn checkout http://touchcode.googlecode.com/svn/trunk/ touchcode-read-only
Does touchXML implement the xmlXPathRegisterNs method and allow the user to do an XPath Search using namespace prefixes?
License question, how do you interpret the MIT license clause "include a copy of the license with your distribution" on the iPhone? Do we need to provide the MIT license in an About page, or is it needed at all?
Has someone successfully integrated libtidy with TouchXML ? The URL I want to analyse gives me lots of parser errors and cannot be analysed with TouchXML.
I have integrated libtidy with TouchXML. I'll look at adding it.
BTW Great TouchXML tutorial here: http://dblog.com.au/general/iphone-sdk-tutorial-building-an-advanced-rss-reader-using-touchxml-part-1/
I've created TouchCode? Dev Google Group. This is now the preferred forum for TouchCode? related development questions: http://groups.google.com/group/touchcode-dev
Please, what is the new address for the SVN checkout? I had this one, and it is not working...
svn checkout http://touchcode.googlecode.com/svn/trunk/ touchcode-read-only Thx in advance for any help!
they use mercurial now (for some odd reason...)