Serialize a XML file with Thrift ? PHP or Ruby

10 views
Skip to first unread message

alexis...@crisalid.com

unread,
May 26, 2014, 10:20:44 AM5/26/14
to thri...@googlegroups.com
Hi,

I'm a engineering student and I'm interested by Thrift.
I have many XML files which I would like to convert into Thrift binaries file. Because I would like to store them.
I don't understand and I don't find any examples in PHP or RUBY.

Here an example of my XML file :
####################
<?xml version="1.0" encoding="UTF-8"?>
<book version="2">
    <entete>
        <creation iso="65486">
            <date>22052014</date>
        </creation>
        <cab>DONNEECABICI</cab>
    </entete>
    <lignes no="2">
        <article no="1">
            <libelle>PIZZA</libelle>
        </article>
        <article no="2">
            <libelle>KEBAB</libelle>
        </article>
    </lignes>
</book>
####################

I did the Thrift schema :

####################
typedef i32 int
struct Creation {
    1: int a_iso
    2: int date
}
struct Entete {
    1: Creation elt_Creation
    2: string cab
}
struct Article {
    1: int a_no
    2: string libelle
}
struct Lignes {
    1: int a_no
    2: Article elt_Article
}
struct Book {
    1: int a_version
    2: Entete elt_Entete
    3: Lignes elt_Lignes
}
####################

I use PHP (but afterwards, I'll use Ruby) and I didn't arrive to serialize my xml file.

In PHP, I parse my xml file with simplexml_load so I have a "SimpleXMLObject".
In Ruby, I'll parse my xml file with "Hash.from_xml(xml)" so I'll have a Hash object.

Help me please... ( I have passed 2 weeks on... )

Thank you very much !
Reply all
Reply to author
Forward
0 new messages