Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4362: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4364: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4365: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4366: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
anddev.org • View topic - Problem with parsing xml file

Problem with parsing xml file

Put your problem here if it does not fit any of the other categories.

Problem with parsing xml file

Postby alphajin » Fri Feb 22, 2008 8:32 am

I have code to parse xml file. but it was puzzled that when I tried to get the attribute of any node with methode getAttributes() no matter this node had attr or not, this methode always return false.

I have the same code and parse the same xml file, it worked!

So can some guys explain this ?
alphajin
Freshman
Freshman
 
Posts: 5
Joined: Tue Feb 19, 2008 2:18 pm

Top

Postby Jodol » Fri Feb 22, 2008 9:10 am

Can you post your code?
Member of a Dutch company developing applications for Android.
ColdTrick Solutions
User avatar
Jodol
Junior Developer
Junior Developer
 
Posts: 16
Joined: Wed Dec 19, 2007 6:29 pm
Location: Netherlands

Postby alphajin » Fri Feb 22, 2008 9:20 am

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. People people = new People();
  2.  
  3. Class<People> pc = People.class;
  4.  
  5. NodeList nl = el.getChildNodes();
  6.  
  7.  
  8.  
  9. for(int i=0;i<nl.getLength();i++){
  10.  
  11.    Node n = nl.item(i);
  12.  
  13.    if(n.getNodeType() == Node.ELEMENT_NODE){
  14.  
  15.           displayNodeInfo(n);
  16.  
  17.            Element e =(Element)n;
  18.  
  19.            String name = ((Element)n).getTagName();
  20.  
  21.             Field f;
  22.  
  23.             if(name.equals("db:location")){     {
  24.  
  25.         f = pc.getDeclaredField("location");
  26.  
  27.             }else{
  28.  
  29.         f = pc.getDeclaredField(name);
  30.  
  31.             }
  32.  
  33.             if(e.hasChildNodes() == true)
  34.  
  35.            {
  36.  
  37.         Text text =(Text)e.getFirstChild();
  38.  
  39.             }
  40.  
  41.            if(e.hasAttributes()){
  42.  
  43.         System.out.println("run here");
  44.  
  45.         NamedNodeMap nnm = e.getAttributes();
  46.  
  47.         for(int k=0; k<nnm.getLength();k++)
  48.  
  49.         {
  50.  
  51.              Node attr = nnm.item(0);
  52.  
  53.         }
  54.  
  55.            }
  56.  
  57.        }
  58.  
  59. }
  60.  
  61.  
  62.  
  63. return people;
Parsed in 0.022 seconds, using GeSHi 1.0.8.4
alphajin
Freshman
Freshman
 
Posts: 5
Joined: Tue Feb 19, 2008 2:18 pm

Postby plusminus » Fri Feb 22, 2008 10:16 pm

Hello alphajin,

why not working with a SaxParser :?:
Tutorial: :arrow: :src: http://www.anddev.org/viewtopic.php?t=353

Btw: System.out.println(...) doesn't work. In Android use LogCat instead.
Example: :arrow: :src: http://www.anddev.org/viewtopic.php?t=118

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby alphajin » Sun Feb 24, 2008 5:30 am

Plusminus
This code is well running in Java. In Android, you should change System.out.println to Log.i().

I am not farmilar with SaxParser, and I just want to know if it's bug in Android or not. :)

And thanks your help:)


Best regards,
Alpha
alphajin
Freshman
Freshman
 
Posts: 5
Joined: Tue Feb 19, 2008 2:18 pm

Postby plusminus » Sun Feb 24, 2008 9:48 pm

Hello alphajin,

sorry, never did xml-parsing like that.

Where do you import that functionality from. Maybe it was rewritten by Google and is placed in an android.xyz-package.

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot] and 15 guests