File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Services and the fly likes XML Serializer (C# to Java) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "XML Serializer (C# to Java)" Watch "XML Serializer (C# to Java)" New topic

XML Serializer (C# to Java)

Yahya Elyasse
Ranch Hand

Joined: Jul 07, 2005
Posts: 510


I want to convert below c# code into java .i appreciate your help.

Peer Reynders

Joined: Aug 19, 2005
Posts: 2933
I'd be surprised if anybody could help you based on that code snippet. The design philosophy of the .NET XML processing API is quite different from the Java XML code processing APIs. The only information that is communicated is that the document contains "attendee" elements. XmlSerializer is an implementation of a .NET specific object serialization/de-serialization protocol that isn't directly supported in Java. (TopXML: XMLSerializer .NET Tutorial (PDF)) Java's java.beans.XMLEncoder and java.beans.XMLDecoder follow the same idea as XmlSerializer but they use their own style of XML, so the aren't interoperable with XmlSerializer.

  • If you can, try to get the XML Schema for the XML. Sometimes the Schema is sent inline with the document.
  • At the very least get a sample of the XML that you need to parse - if necessary this may allow you to create your own schema.
  • If you cannot get either then you need to get a hold of the complementary serialization code and find a .NET development environment so that you can generate your own sample documents.

  • Once you have a schema or samples you can use your choice of Java XML processing API to access the information that you need: SAX, DOM, StAX, JAXP, XPath etc.

    If you have a schema and don't mind the dependencies on the JAXB jars then JAXB can generate the serialization/de-serialization code for you.

    Otherwise XPath can be a good solution especially if you are only interested in part of the data.
    I agree. Here's the link:
    subject: XML Serializer (C# to Java)
    It's not a secret anymore!