@Root
public class DataSet {
@Namespace()
@Path("")
private String WordKey;
private String Pron;
private String Orig;
private String Trans;
}
I want use retrofit2
with simplexml
to transform http request. It's android code. I have trouble with transform xml. How to transform this ? How can i write the class ?
<DataSet xmlns="http://WebXml.com.cn/">
<xs:schema xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="Dictionary">...</xs:schema>
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<Dictionary xmlns="">
<Trans diffgr:id="Trans1" msdata:rowOrder="0">
<WordKey>hello</WordKey>
<Pron>'heləu, he'ləu</Pron>
<Info/>
<Translation>int.(见面打招呼或打电话用语)喂,哈罗</Translation>
<Mp3>1059.mp3</Mp3>
</Trans>
<Sentence diffgr:id="Sentence1" msdata:rowOrder="0">
<Orig>
She actually condescended to say hello to me in the street today.
</Orig>
<Trans>她今天在街上竟能屈尊跟我打招呼.</Trans>
</Sentence>
<Sentence diffgr:id="Sentence2" msdata:rowOrder="1">
<Orig>
I said hello to her, but she ignored me completely!
</Orig>
<Trans>我向她打招呼, 可她根本不理我!</Trans>
</Sentence>
<Sentence diffgr:id="Sentence3" msdata:rowOrder="2">
<Orig>Hello there, what a coincidence!</Orig>
<Trans>你好,真巧啊!</Trans>
</Sentence>
</Dictionary>
</diffgr:diffgram>
</DataSet>
Found solution by skipping xs:schema
and diffgr:diffgram
like this:
@Root(name = "DataSet", strict = false)
@Namespace(reference = "http://WebXml.com.cn/")
public class DataSet {
@Path("diffgr:diffgram[1]")
@Element(name = "Dictionary", required = false)
private Dictionary dictionary;
}