operaska wrote:
>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
>XML, must validate if it is major or minor that the current one and
>to modify it.
>how I can do this?
>
>I'm work with xpp3
>
>
modify Roundtrip to have parser read from string (StringReader) and
serializer to write back XML into string (StringWriter)
alek
>--- In xmlpull-user@yahoogroups.com, Aleksander Slominski
><aslom@c...> wrote:
>
>
>>operaska wrote:
>>
>>
>>
>>>Hello
>>>
>>>Thanks in advance
>>>
>>>I try this and generate
>>>
>>>java.lang.IllegalArgumentException: startTag() must be called
>>>
>>>
>before
>
>
>>>attribute()
>>>
>>>What i can do?
>>>
>>>
>>>
>>>
>>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 xpp3:
>>http://www.extreme.indiana.edu/dist/java-repository/xpp3/jars/)
>>
>>now if you make my modifications what exactly is failing? what is
>>modified source code?
>>
>>alek
>>
>>
>>
>>>--- In xmlpull-user@yahoogroups.com, Aleksander Slominski
>>><aslom@c...> wrote:
>>>
>>>
>>>
>>>
>>>>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.ja
>>
>>
>v
>
>
>>>a
>>>
>>>
>>>
>>>
>>>>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
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>>Yahoo! Groups Links
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>--
>>The best way to predict the future is to invent it - Alan Kay
>>
>>
>
>
>
>
>
>Yahoo! Groups Links
>
>
>
>
>
>
>
>
--
The best way to predict the future is to invent it - Alan Kay