aspose file tools*
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


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "XML Serializer (C# to Java)" Watch "XML Serializer (C# to Java)" New topic
Author

XML Serializer (C# to Java)

Yahya Elyasse
Ranch Hand

Joined: Jul 07, 2005
Posts: 510

hi,

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

Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2906
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.


    "Don't succumb to the false authority of a tool or model. There is no substitute for thinking."
    Andy Hunt, Pragmatic Thinking & Learning: Refactor Your Wetware p.41
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: XML Serializer (C# to Java)
     
    Similar Threads
    trimming down a string
    DOM contents to string instead of a file...
    Editing data after retrieving from XML file and saving again
    Generating XML
    Reading XML using the XSD schema file.