Is there something like JAX-B for C #?

We are looking for a library that supports marshalling and unmarshalling, like JAX-B in Java, is there any modern library to use?

+4
source share
3 answers

As Bruno said, what you are looking for is in the System.Xml.Serialization namespace, specifically the XmlSerializer . To serialize an object in XML, you just need to call the Serialize method, and you can do the opposite with Deserialize . For more information, see the MSDN Topic View XML Serialization .

Sometimes when XML crashes, you can hit, if you have problems, be sure to check (and contribute) to this stream .

+4
source

System.Xml.Serialization Namespace is what you need. It can work with attributes such as Java annotations.

+1
source

There is something like, but not quite like JAXB. Similar is expressed by Allon Guralnek and Bruno Conde. The difference is deserialization. Using XmlSerializer you must specify the type. The type can come from the XSD file, the XML Schema, which is processed using the XSD.EXE tool. The tool creates a cs file with partial classes for each specific type in the XML schema. It is convenient to use.

But you cannot use derserializer in XmlSerilaizer unless you have a type for valid xml. The script may look like this. You receive xml messages from the message queue. You can get any of the types defined in the XML schema. With JAXB, you wrap xml into an object and use the getClass property to determine what type it is. I have not found a similar way to do this in C #.

0
source

All Articles