xml-deserialization

Perl deserialize XML

走远了吗. 提交于 2019-12-09 02:26:28
I have XML file (output of some application) like this: <data> <call function="get_user_data"> <output> <integer name="my_id" value="-31" /> <string name="login" value="root" /> <integer name="ip_list" value="2" /> <array name="i"> <item> <ip_address name="user_ip" value="0.0.0.0" /> <ip_address name="user_mask" value="0.0.0.0"/> </item> <item> <ip_address name="user_ip" value="94.230.160.230" /> <ip_address name="user_mask" value="255.255.255.0"/> </item> </array> <integer name="modules" value="2" /> <array name="i"> <item> <string name="module_name" value="core" /> </item> <item> <string

Simple xml framework deserializing with multiple element names

人盡茶涼 提交于 2019-12-08 07:39:23
问题 I am trying to serialize some xml data from a public web service into java objects with Simple XML Framework. The problem is that different methods from the service return the same concept with different element names. For example, method A returns element foo like this <data><Foo>foo value</Foo></data> whereas method B returns <data><foo>foo value</foo></data> and method C returns <data><FOO>foo value</FOO></data> Is there any way (a multiple name annotation or so) of getting this xml

XmlDocument.Load() method fails to decode € (euro)

随声附和 提交于 2019-12-08 06:15:37
问题 I have an XML document file.xml which is encoded in Iso-latin-15 (aka Iso-Latin-9) <?xml version="1.0" encoding="iso-8859-15"?> <root xmlns="http://stackoverflow.com/demo"> <f>€.txt</f> </root> From my favorite text editor, I can tell this file is correctly encoded in Iso-Latin-15 (it is not UTF-8). My software is written in C# and wants to extract the element f . XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load("file.xml"); In real life, I have a XMLResolver to set credentials. But

Simple xml framework deserializing with multiple element names

时光毁灭记忆、已成空白 提交于 2019-12-08 02:36:32
I am trying to serialize some xml data from a public web service into java objects with Simple XML Framework. The problem is that different methods from the service return the same concept with different element names. For example, method A returns element foo like this <data><Foo>foo value</Foo></data> whereas method B returns <data><foo>foo value</foo></data> and method C returns <data><FOO>foo value</FOO></data> Is there any way (a multiple name annotation or so) of getting this xml deserialized into the same class and same element? For example, deserializing the three method's results into

How to Deserialize xml to an array of objects?

和自甴很熟 提交于 2019-12-07 13:59:56
问题 I am tryind to deserialize a xml file into an object[] - the object is a rectangle with the following fields public class Rectangle : IXmlSerializable { public string Id { get; set; } public Point TopLeft { get; set; } public Point BottomRight { get; set; } public RgbColor Color { get; set; } } I created several rectangles, saved them into an array and managed to serialize them into the xml i get the following syntax: <?xml version="1.0" encoding="utf-8" ?> - <Rectangles> - <Rectangle> <ID

Deserialize xml into super class object with C#

丶灬走出姿态 提交于 2019-12-07 02:35:57
问题 I'm creating a program that allow user define formulas with on 4 basic operation: add, subtract, divide, multiple using XML. Let's take an example: User want to define formula like (a + b) x (c + d) . The format of the xml as following: EDIT I had implement this EDIT Solve. Many thanks to Yaniv 's suggestion. My solution as follow: <xPlugins> <xPlugin> <Multiple> <Add> <Operator> <value>1</value> </Operator> <Operator> <value>2</value> </Operator> </Add> <Add> <Operator> <value>3</value> <

Deserialize XElement into Class(s)

烈酒焚心 提交于 2019-12-06 17:00:54
问题 I am trying to Deserialize an XML file into a few class objects: Artist, Album, and Songs Here is the current setup: static void Main(string[] args) { var riseAgainst = DeSerializer(CreateElement()); Console.WriteLine(string.Format("Band: {0}",riseAgainst.Name)); Console.WriteLine("-----------------------------"); Console.WriteLine(string.Format("Album: {0}",riseAgainst.Album.Name)); Console.WriteLine("-----------------------------"); Console.WriteLine("Song List:\r"); foreach(var s in

require either one element or the other in JAXB

≡放荡痞女 提交于 2019-12-06 13:37:07
I have a JAXB-annotated POJO like this: @XmlRootElement @XmlAccessorType(XmlAccessType.FIELD) public class Clazz implements Serializable { @XmlElement(required = false) private int a; @XmlElement(required = false) private int b; } I want to mark that either field a or field b is required. With my current set-up, none of them are required, but I want one of them to be present and not the other. How could I achieve it? You can do the following with @XmlElementRefs Domain Model Clazz import java.io.Serializable; import javax.xml.bind.JAXBElement; import javax.xml.bind.annotation.*;

XmlSerialization with a singleton

我们两清 提交于 2019-12-06 08:46:43
Serialization woes continue ... I'm trying to serialize a class, instances of which share between them common objects (a binder of sorts). So, objects A, B, C share object Binder1, and objects D and E - Binder2, and so on... I'm serializing objects A,B,C,D,E. Typically, this binder object is passed in a constructor - not with the serializer though, since it needs a parameterless constructor. ISeriazable seems to have something that works for singletons - IObjectReference interface, where the method GetRealObject can be used to return a reference to the newly created singleton. But, it doesn't

Cannot deserialize with XMLSerializer result from WCF webservice

穿精又带淫゛_ 提交于 2019-12-05 10:58:15
Here is the code trying from compact framework to get http service.. List<Table> tables; using (Stream r = response.GetResponseStream()) { XmlSerializer serializer = new XmlSerializer(typeof(Table),"http://schemas.datacontract.org/2004/07/"); tables=(List<Table>) serializer.Deserialize(r); } response.Close(); It fails with {"There is an error in XML document (1, 2)."} {"<ArrayOfTable xmlns='http://schemas.datacontract.org/2004/07/WpfApplication1.Data.Model'> was not expected."} Table namespace is the same... I dont know whats wrong there... UPDATE Problem was that i had typeof(Table) not