Search the web
Sign In
New User? Sign Up
xmlpull-user
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Real people. Real stories. See how Yahoo! Groups impacts members worldwide.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Re: Modify attributes   Message List  
Reply | Forward Message #208 of 308 |
operaska wrote:

>Hello
>
>My name is Jose, i'm try to modify an attribute, but a specific
>attribute see this
>
><xml>
> <field1>
> <internal_field1 name="example" date="01-06-05:12:00"/>
> </field1>
>
>How i cant to modify the attribute date ?
>
>are there some like this ?
>while (EventType != XmlPullParser.END_DOCUMENT) {
>.
>.
>.
> if(xpp.getName().equals("internal_field1")){
> //I don't know some like this
> if(xpp.getAttributeName(i).equals("date")){
> setAttribute("12-12-05:12:00:00");
> }
> }
>}
>
>
>
>
XmlPullParser parser can not modify anything (it is only reading) - you
need XmlSerializer (to write), check this example:
http://xmlpull.org/v1/download/unpacked/src/java/samples/Roundtrip.java

and modify writeStartTag to write your attribute anyway you want, that
may work:

for (int i = 0; i < parser.getAttributeCount (); i++) {
if(xpp.getAttributeName(i).equals("date")){
serializer.attribute
(parser.getAttributeNamespace (i),
parser.getAttributeName (i),
"12-12-05:12:00:00");
} else {
serializer.attribute
(parser.getAttributeNamespace (i),
parser.getAttributeName (i),
parser.getAttributeValue (i));
}
}


HTH,

alek

--
The best way to predict the future is to invent it - Alan Kay




Wed May 4, 2005 4:36 pm

as10m
Offline Offline
Send Email Send Email

Forward
Message #208 of 308 |
Expand Messages Author Sort by Date

... XmlPullParser parser can not modify anything (it is only reading) - you need XmlSerializer (to write), check this example: ...
Aleksander Slominski
as10m
Offline Send Email
May 4, 2005
4:36 pm

Hello Thanks in advance I try this and generate java.lang.IllegalArgumentException: startTag() must be called before attribute() What i can do? ... you ... ...
operaska
Offline Send Email
May 4, 2005
6:00 pm

... did you get unmodified Roundtrip to work? i am pretty sure it works. makes sure you use the latest version of xmlpull compatible parser (i test it with...
Aleksander Slominski
as10m
Offline Send Email
May 4, 2005
6:12 pm

Thank you for answering My question is the following one: I have a String with format XML, to which I want to validate him the date that is an attribute of the...
operaska
Offline Send Email
May 4, 2005
7:11 pm

... modify Roundtrip to have parser read from string (StringReader) and serializer to write back XML into string (StringWriter) alek ... -- The best way to...
Aleksander Slominski
as10m
Offline Send Email
May 4, 2005
7:19 pm

... study API, samples, and read about xmlpull: http://www.cafeconleche.org/books/xmljava/chapters/ch05s09.html and if you do not understand XML parsing then...
Aleksander Slominski
as10m
Offline Send Email
May 4, 2005
8:24 pm

Many Many Many Thanks, xpp is the best parser XML that I have seen. Thank you again Please he looks at this: ...
operaska
Offline Send Email
May 4, 2005
9:54 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help