C: How to parse XML in android? - android

I'm working to create a library for my app in C. I want to parse a XML file in my code.
So, how can i do it in C ?
I know its java implementation but how can i parse a XML in my C code ?
What are the libraries that can be used for the purpose ?

I suggest Expat, I've used with many projects and it is very simple to use and has extremely small overhead. Its code base is also quite stable.
Expat is an XML parser library written in C. It is a stream-oriented parser in which an application registers handlers for things the parser might find in the XML document (like start tags).
However with every other external project mentioned, you need to build it yourself.

you should use c library for parsing xmls. here are some famous library links.. you can check
http://www.jclark.com/xml/expat.html
http://www.xmlsoft.org/
http://tibleiz.net/asm-xml/benchmark.html
you can find many other library to parse xml. But if you have any lightweight parsing task then you can use
http://www.minixml.org/

I have used http://www.minixml.org/ so i suggest to use this. Minixml is quite simple and easy to understand and use.
So you can download whole code of minixml and cross compile it for Android using Android toolchain or android NDK. And now Link that library to your jni code and use its API in your c code.
Just refference for includeing 3rd party library in jni code see
How to link any library in ndk application

Related

How to convert midi to wav using Timidity++?

I am actually trying to use timidity lib in my android project using the jni interface.
The problem is I need to create the shared lib for that including some C files.
I don't know the C files/classes and methods in them that are used for the above task.
So Please help me ,if any of you C developer have the idea or has the experience of using this library.

using opencv haarcascades in android ndk

I would like to use the facedetection in opencv cpp to use it in an android app. I have compiled jni successfully. But I wonder how would i use the haarcascades. I can store in sdcard and read it from there. Is there any other way i can use the xml files directly from the project?
There is a c++ example called facedetect coming with the opencv superpack. I'm running OpenCV-2.3.1 myself and it's located in this folder: ../opencv-2.3.1/samples/c/
The sample uses haarcascades and this might be your best bet for facedetection. If you can use the Android NDK with proper JNI calls from a .cpp file then you shouldn't have any problems to use this sample.
I'm working on a similar thing myself but haven't tried it myself yet. Should be implementing the thing somewhere next week but can't guarantee it. Let me know if this works out for you

Configuration file XML - Parsing Library C/C++ - Android, IOS, Desktop

I have a large C program which needs to communicate some XML files to Java/Obj-C and other languages. 99% of the program business logic is in C/C++ mix. Java, Obj-C all have a way to parse XML and in most cases I'll be using HTML5 and Javascript (via PhoneGap) to parse the XML on that end. The part that is frustrating is finding a decent C or C++ library that compiles on each platform and is relatively straight forward to use.
I've looked into libxml2 first. It is not easy to get compiling for Android at least, required ICU4 to get working. I then checked out libroxml, unfortunately its xml modification core is weak at best.
Does anyone have a tip for a nice XML Parsing library that isn't hell to compile or use? That supports modification of the XML file? Do I need to be concerned about language support (unicode)?
TinyXML seems like the way to go.
http://sourceforge.net/projects/tinyxml/
Small, supports modification of the tree, utf8 and compiles easily (just a few files, no platform dependencies).

How do I add the javax.swing.* packages to my libs for my android project?

First of all I'd like to mention I am very new to Java programming. This Android project is my first experience with Java. So for one task I need to strip HTML tags from a string. I was thinking about using this answer Remove HTML tags from a String to do this task. In order to do this I need to be able to import javax.swing.text.html.* and javax.swing.text.html.parser.*.
I went to the properties of my project and attempted to add this library to my project. I read that this was included in the rt.jar file which was located at /usr/lib/jvm/java-6-openjdk/jre/lib/rt.jar
I was able to use the imports but it seems like it added a million libraries I am not using. Will this negatively effect my application? What is the correct way to add just the one extension?
You don't. Android doesn't use Swing. You'll need to use Android's API to create your UI and perform text parsing. Consider android.text.Html as a simple way to strip HTML from a string.

Android Converting objects to XML and vice versa

I created a xsd and I created Java objects using Castor. Then I imported this in my Android project and tried to build an XML from the object, using the marshal method.
Marshaller.marshal(v, writer);
I received some wired exception trouble processing "javax/xml/parsers/DocumentBuilder.class":...
So my question is Can I use Castor inside Android, If yes how can I work around this.
If no, what is the neat solution available to convert object to xml and xml to object in Android, similar to Castor.
Thanks in Advance.
I personally do not have any experience with Castor but from the website it would seem that it has dependencies which android does not support and therefore cannot be used inside android.
I ended up using Simple xml from simple.sourceforge.net/home.php. This looks light suitable for Android. But this will not create Java objects for your xsd. You have to create them on your own. Is there a way to build these objects directly from xsd compantible with Android?

Categories

Resources