There definitely is an issue with attributes which won't let you access them unless you know their names beforehand. If that isn't a problem, then it's easy to write some code to give you back an Xml string from a Document.
On Mar 24, 12:09 pm, "Dexter's Brain" <[EMAIL PROTECTED]> wrote: > Hey Vishal, > > This code will work with JDK.....But, currently, there is some problem > with the android SDK. > > The NamedNodeMap doesn't work....I dont know how did you test it on > android. There is also a bug reported for this issue with the SDK.. I > guess.....I tried using this, but it never worked for me....Lot of > other people are also having this problem...... > > Dexter. > > vishal wrote: > > I think i have a code for this which is general with any DOM document > > type... > > > Here initially you have to pass root element. Plz tell me if im > > wrong.... and if errors in the code.. or any way to improve that > > > private void addTagToTheFile(Element elem) throws IOException { > > NamedNodeMap elemAttributes = elem.getAttributes(); > > StringBuffer elemTagTowrite = new StringBuffer(); > > Node attribute ; > > elemTagTowrite.append("<"+elem.getTagName()); > > if(elemAttributes!=null){ > > > > Log.i(elem.getTagName(),""+elemAttributes.getLength()); > > int noOfAttributesInTag = > > elemAttributes.getLength(); > > for(int counter=0; counter < > > noOfAttributesInTag; counter++){ > > attribute = elemAttributes.item(counter); > > elemTagTowrite.append(" " + > > attribute.getNodeName() + > > " = \"" + > > attribute.getNodeValue()+"\""); > > } > > } > > elemTagTowrite.append(">"+'\n'); > > outputFileWriter.write(elemTagTowrite.toString()); > > NodeList childElements = elem.getChildNodes(); > > int noOfchildElements = childElements.getLength(); > > for(int counter=0; counter < noOfchildElements; > > counter++){ > > > if(childElements.item(counter).getClass().toString().contains("Element")) > > { > > Node childNode = > > (Element)childElements.item(counter); > > Element childElement = > > (Element)childNode; > > addTagToTheFile(childElement); > > } > > } > > elemTagTowrite.delete(0, elemTagTowrite.length()); > > elemTagTowrite.append("</" + elem.getTagName() + ">"); > > outputFileWriter.write(elemTagTowrite.toString()); > > outputFileWriter.write('\n'); > > } > > } > > > On Mar 24, 9:59 pm, "Dexter's Brain" <[EMAIL PROTECTED]> wrote: > > > Hello Vesin, > > > > I can give you the code, but its not a generalized one. It will work > > > only for my XML file format. I dont think it will help u. > > > > On Mar 24, 8:32 pm, "Vesin Du�ko" <[EMAIL PROTECTED]> wrote: > > > > > Can you share your code with as? > > > > > On 16/03/2008, Dexter's Brain <[EMAIL PROTECTED]> wrote: > > > > > > Hi Nitin, > > > > > > I think this is not possible with the current SDK. We should wait till > > > > > some more packages are added to the SDK. Till then, everything has to > > > > > be done manually. > > > > > After banging my head for hours, I wrote a method that would convert a > > > > > DOM document object to an xml file. It wasn't very difficult though. > > > > > > Dexter. > > > > > -- --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] Announcing the new M5 SDK! http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---