Hi Binh Dao Duy,
It works fine for me, 
Anyway, I used JDOM-2 for manipulating XML data, Below is my implemented 
code portion

/* Generating a XML file from Proto the message. */
public void proto2Xml(Message message) {
SAXBuilder builder = new SAXBuilder();
Document document;
XMLOutputter outputter;
try {
document = builder.build(new 
ByteArrayInputStream(XmlFormat.printToString(message).toString().getBytes()));
outputter = new XMLOutputter();
outputter.setFormat(Format.getPrettyFormat());
System.out.println("++++++++PROTO2XML++++++++++++++++++++");
outputter.output(document, System.out); // XML Console out.
System.out.println("++++++++++++++++++++++++++++++++++++++");
outputter.output(document, new FileWriter(xmlFilePath));
} catch (JDOMException e) {
System.out.println("JDOMException : " + e.getMessage());
} catch (IOException e) {
System.out.println("IOException : " + e.getMessage());
}
} // End of proto2Xml.


Thanks,
Pradeep

On Monday, March 25, 2013 7:00:17 PM UTC+8, Binh Dao Duy wrote:
>
> I think you should try with this 
> https://code.google.com/p/protobuf-java-format/
>
> Vào 16:26:19 UTC+7 Thứ hai, ngày 25 tháng ba năm 2013, PraYes đã viết:
>>
>> I spent whole day to convert a protocol buffers message into an XML 
>> file(should be done both direction xml-proto, proto-xml), unfortunately I 
>> couldn't do that as expected. I have used here JDOM2 as xml parser. please 
>> anyone help or suggest me to produce XML/Proto message using protocol 
>> buffers?
>>
>> My protocol Message as below,
>> message RoutePoint {
>>     required double x = 1;
>>     required double y = 2;
>>     optional double z = 3;
>>     optional double orientation = 4;
>> }
>>
>> message WayPoint {
>>     required uint32 route_id = 1;
>>     required RoutePoint point = 2;
>> }
>>
>> message RouteWay {
>>     optional uint32 command_ref = 1;
>>     required uint32 grant_id = 2;
>>     optional WayPoint begin_point = 3;
>>     required WayPoint end_point = 4;    
>> }
>>
>> I tried with JAXB to Marshalling and Unmarshalling but is also doesn't 
>> support to this. 
>> Appreciate if provide an example for my case.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to