xml-deserialization

How do I Deserialize xml document with namespaces using XmlSerializer?

北慕城南 提交于 2019-12-01 20:40:10
When deserializing a document using XmlSerializer are not deserialized correctly Document <?xml version=\"1.0\"?> <ns0:ElementA xmlns:ns0=\"urn:some-namespace\"> <Prop1>Some Value</Prop1> <Prop2>Some other value</Prop2> </ns0:ElementA> Class [XmlRoot(Namespace = "urn:some-namespace")] public class ElementA { [XmlElement] public string Prop1 { get; set; } [XmlElement] public string Prop2 { get; set; } } Both Prop1 and Prop2 are null at the end of the deserialization. I cannot change the structure of the document to get rid of the namespace so I need to handle the deserialization properly on my

Deserialization of xml with simplexml in java

僤鯓⒐⒋嵵緔 提交于 2019-12-01 19:29:15
I'm trying to deserialize an xml string with SimpleXML, i've looked at their examples but i'm not really sure that wether i grasp the concept or not. Sample XML (validates): <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <Response xmlns="http://localhost/webservices/"> <Result> <Item><ID>0</ID><language /><price>168</price></Item> <Item><ID>1</ID><language /><price>178</price></Item> <Item><ID>2</ID><language /><price>195<

Deserialize xml to object with Symfony2

瘦欲@ 提交于 2019-12-01 18:11:27
问题 I collect some data in xml format through an API and would like to deserialize it in an objects list. I'm using Symfony2 and find out JMSSerializerBundle but I do not really know how to use it. I know that Sf2 allows to serialize/deserialize object to/from array, but I'm looking for something more specific. For example, for this class : class Screenshot { /** * @var integer $id */ private $id; /** * @var string $url_screenshot */ private $url_screenshot; public function __construct($id, $url

Proguard - PersistenceException: Constructor not matched for class

坚强是说给别人听的谎言 提交于 2019-12-01 15:59:15
问题 I am using retrofit2.0 in my app with simpleframework.xml library. The problem is when I run the app without proguard it works fine however when I run proguard I get the following Error in logs. E/ERROR: java.lang.RuntimeException: org.simpleframework.xml.core.PersistenceException: Constructor not matched for class A The class A has no/default constructor which should work. Still I added a No Argument Constructor . But that didn't rectify the issue. Class A @Root(name = "data",strict = false)

Best way to parse xml in Appengine with Python

假如想象 提交于 2019-12-01 05:45:30
I am connecting to isbndb.com for book information and their response looks like this: <?xml version="1.0" encoding="UTF-8"?> <ISBNdb server_time="2005-02-25T23:03:41"> <BookList total_results="1" page_size="10" page_number="1" shown_results="1"> <BookData book_id="somebook" isbn="0123456789"> <Title>Interesting Book</Title> <TitleLong>Interesting Book: Read it or else..</TitleLong> <AuthorsText>John Doe</AuthorsText> <PublisherText>Acme Publishing</PublisherText> </BookData> </BookList> </ISBNdb> What is the best way to turn this data into an object using appengine (Python)? I need the isbn

C# XML Insert comment into XML after xml tag

情到浓时终转凉″ 提交于 2019-11-30 23:14:45
I am using a C# object to Serialize/Deserialize XML. I would like to add a comment to the XML file whilst serializing, this comment will be a basic <!-- comment --> after the standard xml tag <?xml version="1.0" encoding="UTF-8"?> This comment does not need to be deserialized, its a basic comment to indicate the product and version that created the xml file. Serialize it to XML, load that XML as an XDocument (or whatever API you want), insert the comment, save it out again. Simple, and should work with whatever API you want to use. You can do it all in memory using a MemoryStream as the

Can't use XMLGregorianCalendar in Android, even if it is documented?

最后都变了- 提交于 2019-11-30 21:29:05
I really can't understand this one: it looks like Android has the XMLGregorianCalendar class, because it is documented here . But if you go ahead and try to use it, that's what you get: 10-27 17:21:43.677: E/AndroidRuntime(14850): Caused by: javax.xml.datatype.DatatypeConfigurationException: Provider org.apache.xerces.jaxp.datatype.DatatypeFactoryImpl not found 10-27 17:21:43.677: E/AndroidRuntime(14850): at javax.xml.datatype.DatatypeFactory.newInstance(DatatypeFactory.java:102) This happens on the line: DatatypeFactory datatype = DatatypeFactory.newInstance(); And guess what, it should not

Deserialize Xml with empty elements

偶尔善良 提交于 2019-11-30 20:34:25
Consider the following XML: <a> <b>2</b> <c></c> </a> I need to deserialize this xml to an object. So, i wrote the following class. public class A { [XmlElement("b", Namespace = "")] public int? B { get; set; } [XmlElement("c", Namespace = "")] public int? C { get; set; } } Since i'm using nullables, i was expecting that, when deserialing the above xml, i would get an object A with a null C property. Instead of this, i get an exception telling the document has an error. There's a difference between a missing element and a null element. A missing element, <a><b>2</b></a> . Here C would take

XML deserialization crashes on decimal parse due to formatting

淺唱寂寞╮ 提交于 2019-11-30 20:22:55
I get a System.FormatException thrown when i try to parse XML into an object. As far as I can tell, it's due to the culture used in System.Xml.Serialization.XmlSerializer.Deserialize, wich expects a dot as the decimal character, but the xml contains a comma. The object looks as follows: public sealed class Transaction { [XmlElement("transactionDate")] public DateTime TransactionDate { get; set; } [XmlElement("transactionAmount")] public decimal Amount { get; set; } [XmlElement("transactionDescription")] public string Description { get; set; } [XmlElement("transactionType")] public int Type {

C# XML Insert comment into XML after xml tag

不打扰是莪最后的温柔 提交于 2019-11-30 18:24:59
问题 I am using a C# object to Serialize/Deserialize XML. I would like to add a comment to the XML file whilst serializing, this comment will be a basic <!-- comment --> after the standard xml tag <?xml version="1.0" encoding="UTF-8"?> This comment does not need to be deserialized, its a basic comment to indicate the product and version that created the xml file. 回答1: Serialize it to XML, load that XML as an XDocument (or whatever API you want), insert the comment, save it out again. Simple, and