Hi,
need a help regarding SAX Parsing in Android.
I have code in XML file Having List of attributes of innertags.
outertag->innertag--> 1st attribute
-> 2nd attribute
-> 3rdattribute
How I could store these in vector..
would anyone provide me solution How could I DISPLAY Vector in oncreate() method.
Found this SAX example: http://www.anddev.org/parsing_xml_from_the_net_-_using_the_saxparser-t353.html
Dont understand the difficulty you're having in using a Vector, its just another collection....
http://www.roseindia.net/java/beginners/vectordemo.shtml
Related
New Version, v2.3
# v2.3 Minor tweak to allow passing a filename instead of
# naruzo 20080117 an XML string
# Added option to disable string shrinking (shrinkString)
# Added a filter option. filterType can be "include" or "exclude"
#
Click to expand...
Click to collapse
I bundled RSSWeather.mscr (an example script that accesses Yahoo! weather feeds), the readme and the parser into one archive. The only file necessary to use the parser itself is parseXML.mscr.
There is also a new example included in the archive, topStories.mscr, which is a tool to access the Yahoo! top stories news feed (http://rss.news.yahoo.com/rss/topstories) and utilizes the new filterTags functionality to improve performance. The script reads each news item, pulls down the image file from Yahoo!'s site and stores several pieces of information in the registry for use in other scripts/rlToday/etc.
==================================================
Hello there!
I wrote an XML parser for Mortscript. From the synopsis:
parseXML.mscr is an XML parser written in Mortscript.
Writing a custom parser for every application tends to waste a lot of effort and time. Although a custom script for 1 particular application may be faster, parseXML.mscr simply offers a way to parse any XML into an easily accessible data structure with minimum coding/Mortscript experience.
The initial use case was to parse a Yahoo! weather RSS feed for use in my rlToday home screen (RSSWeather.mscr) An example script for parsing the Yahoo! Top Stories feed also exists (topStories.mscr)
parseXML is not staggeringly fast, but several options exist that can improve performance. I have not run it against any particularly hairy XML, but in theory it should be able to handle any well-formed XML.
Click to expand...
Click to collapse
### Output:
The following XML:
<rss version="2.0" >
<channel>
<title>ChannelTitle</title>
<item>
<title>ItemTitle</title>
<description lang="en" country="US">This is the description</description>
</item>
</channel>
</rss><!-- Published by blah 2007 -->
Parses to this data structure:
struct["rss"]["version"] = 2.0
struct["rss"]["channel"]["title"] = ChannelTitle
struct["rss"]["channel"]["item"]["title"] = ItemTitle
struct["rss"]["channel"]["item"]["description"]["lang"] = en
struct["rss"]["channel"]["item"]["description"]["country"] = US
struct["rss"]["channel"]["item"]["description"]["value"] = This is the description
struct["comment"] = Published by blah 2007
Click to expand...
Click to collapse
Enjoy!
thanks
NOw i go tmore idea on how to do other stuff.
v3patel said:
NOw i go tmore idea on how to do other stuff.
Click to expand...
Click to collapse
I hope so!
The parser uses Mortscript 'references' to build the data structure, which are a new (and very handy) feature as of version 4.1, if I remember correctly.
@naruzopsycho:
I'm trying to understand your xml parser and what the output would be. Is the output data written to registry, or to a specific file? Please forgive me my very limited knowledge about mortscript that I'm unable to understand your file completely.
The real use I have for this is to understand the weather cache file for pointUI, which is written in xml format (please refer to the attachment), to read the temperature and weather code and insert those to registry to update the S2U2 user weather as suggested in this thread:
http://forum.xda-developers.com/showthread.php?t=390841
I have posted the same question in the above thread and I think you may have a better idea of how to read the xml file.
Thank you for your help!
I am just starting with Android Development and have a few minor problems.
First of all, sometimes I don't always know what packages to import. Is there a way to import them automatically? I am coding in Ecplise.
2nd, If, because I am not attentive, I hit the "Run" button but with an XML file opened. This results in making a another xml file name <filename>.out.xml that has errors. If I delete the file I still have a red x on my project folder. And when I try to run the actual java file it sais that the project contains error. The only solution is to delete the entire project and recreate it. But this is uncovinient to always recreate the project, recopy the entire code and everything. Does anyone know how to solve this problem? Thanks
Forgot to mention, the error that appears in the "problems" tab is this: Description
Unparsed aapt error(s)! Check the console for output.
And in the console i have this:
[2010-06-30 19:36:36 - Math Test] Error in an XML file: aborting build.
[2010-06-30 19:37:12 - Math Test] res\layout\main.xml:0: ERROR Resource entry main is already defined.
[2010-06-30 19:37:12 - Math Test] res\layout\main.out.xml:0: Originally defined here.
[2010-06-30 19:37:16 - Math Test] res\layout\main.xml:0: ERROR Resource entry main is already defined.
[2010-06-30 19:37:16 - Math Test] res\layout\main.out.xml:0: Originally defined here.
to import packages ctrl+shift+o
Thanks. Also, I managed to remove the error just by deleting it from the "Problems" tab and forcing a rebuild. Thanks.
Don't you wish smalis referenced xml by their tag name instead of those hex numbers? It would be so much easier to port smalis from one framework to another.
Changing every id that is different from the original fw to the destination fw by hand is feasible, but very time consuming. Thus, I made this little java program to automate the task. It runs in the command line, and takes four arguments: the smali you want to change, the smali to be created, the original public.xml, and the target public.xml
It is meant to be used with the script that is also attached, to change all the smali files in any directory. It should work also in windows, but I don't include a .bat file since I only tested this in ubuntu.
the idea is to use it like this:
Code:
./changeAllIds.sh in/ out/ original.xml target.xml > log 2 > err.log
Known issues/bugs/TODO-list:
- The bad news is that the program will throw an exception if there is an id in the smali file that is present in the original.xml but not in the target.xml. The good news is that it will output to stderr the name of the smali file and the line that has that reference, so you can immediately know which one is and add it to the target fw.
- For some reason, the ids 'ok' and 'cancel' will make this program crash. It was for me faster to temporally remove those references in the smali file and continue (adding them back later) rather than fixing the code. You're welcome to fix it if you feel like.
Source code can be found here:
https://github.com/aleadam/xml_id_changer
Well, thank you Sine for linking me to another post in the Vibrant forum.
There is a java program made by untermensch posted 3 days ago that does the same. Except, as judging by the description and the comments, that it's well done, as opposed to the crude and amateur code I posted above
http://forum.xda-developers.com/showthread.php?t=945637
Hi all.
I need to do a close source library for my work.
I figured I could create a library project and then export all of its code into a compiled jar archive.
Then, when I need to use that library, I use the empty android library project for its resources and I import the jar file in the build path.
So far, it works when the main project that uses the library doesn't have its own resources.
But as soon as I add a resource (like icon.png) into the main project, the application fails to launch a library activity and I get this error : Unable to start activity ComponentInfo{...}: android.content.res.Resources$NotFoundException: File res/drawable/icon.png from xml type layout resource ID #0x7f020000
I really don't get it. What's the problem ?
Thank you for your help.
Hi
In "Hello Android" book that i am reading , there is a sentence about usefulness of Resources that i can't understand .
Please give me some help about it .
The paragraph is :
"The resource compiler compresses and packs your resources and then
generates a class named R that contains identifiers you use to reference
those resources in your program. This is a little different from standard
Java resources, which are referenced by key strings. Doing it this way
allows Android to make sure all your references are valid and saves
space by not having to store all those resource keys. Eclipse uses a
similar method to store and reference the resources in Eclipse plug-ins."
The underlined sentence has two part .
I understand part one in this way :
When there is some error in for example XML lay out files in Android project in Eclipse IDE ,
The IDE does not work correctly and some red signs are appeared next to files that have
error in left side project browser of Eclipse.
Is the thing that i understood is correct and complete ???
And about part two .
I cant understand it . What it says ??
Thanks for your help
peter.sorotokin said:
Hi
In "Hello Android" book that i am reading , there is a sentence about usefulness of Resources that i can't understand .
Please give me some help about it .
The paragraph is :
"The resource compiler compresses and packs your resources and then
generates a class named R that contains identifiers you use to reference
those resources in your program. This is a little different from standard
Java resources, which are referenced by key strings. Doing it this way
allows Android to make sure all your references are valid and saves
space by not having to store all those resource keys. Eclipse uses a
similar method to store and reference the resources in Eclipse plug-ins."
The underlined sentence has two part .
I understand part one in this way :
When there is some error in for example XML lay out files in Android project in Eclipse IDE ,
The IDE does not work correctly and some red signs are appeared next to files that have
error in left side project browser of Eclipse.
Is the thing that i understood is correct and complete ???
And about part two .
I cant understand it . What it says ??
Thanks for your help
Click to expand...
Click to collapse
Whenever you add a resource(image, raw file, drawable, etc) in your app package, a separate class named as R.java forms in your gen folder. This cannot be edited by you and can only be modified by the IDE. All your resources will be given a unique id by which you can refer to them from your Java classes. It will revert to the generated version if you try to modify it manually.
I guess that the way you understood the first part is correct. But it also applies to Java code. In the Android Java code you use these identifiers to load resources. You don't use hard-coded Strings. That way the compiler can check whether a resource with that name exists by checking whether the reference to the field in R is valid. If you had to put in hard-coded Strings, there would be no (easy) way to check that.
About the second part: I guess that it means that Strings need more storage space.
If we talk about usefulness of resources, this is a much bigger point to me: You can define different resources for portrait and landscape mode, for different countries, for different screen sizes, for different OS versions, etc. and Android cares about using the right one. You don't need to decide which one to use yourself.
You can also refer to them from Java and xml very easily. You just need to change one line of code to change a String that is used multiple times in your app. You can't forget one.
Link for a much more detailed description: http://developer.android.com/guide/topics/resources/overview.html (including the sub-topics)
However, I guess that you won't need that many details in the beginning. Your book should explain the most important things.