Protocol Buffer Format for Child XML Elements

29 views
Skip to first unread message

yalmasri

unread,
Sep 11, 2011, 5:47:08 AM9/11/11
to protobuf-java-format
Hello,

How do I write an equivalent to this XML in PB notation?

<Person>
<id>3</id>
<name>my name</name>
<motto>you have to attempt the absurd in order to achieve the
impossible</motto>
<gender>1</gender>
<Address>
<street>street</street>
</Address>
</Person>

This is not working:

message Person {
required int32 id = 1;
optional string name = 2;
optional string motto = 3 [default="When the cat is away, the mouse
is alone!"];
enum Gender {
MALE = 1;
FEMALE = 9;
}
optional Gender gender = 4;
message Address {
required string street = 1;
optional string pob = 2;
}
repeated Address address = 5;
}

as it generates this:

Person>
<id>1</id>
<name>my name</name>
<motto>you have to attempt the absurd in order to achieve the
impossible</motto>
<gender>1</gender>
<address>
<Address>
<street>street</street>
</Address>
</address>
</Person>
Reply all
Reply to author
Forward
0 new messages