xml-deserialization

Instance validation error: * is not a valid value for *

瘦欲@ 提交于 2019-12-05 08:26:48
I'm trying to deserialize an XML string, where the value of an element, ain't within the scope of my Enum values. Public enum MyEnum { Unknown, Car, Bicycle, Boat } [SerializableAttribute()] public class MyClass { private string _id; private MyEnum _myEnum; public string ID { get { return _id; } set { _id = value; } } public MyEnum EnumValue { get { return _myEnum; } set { _myEnum = value; } } public MyClass(string id) { this._id = id; } public MyClass() : this("") { } } If I try to deserialize following string (note Plane as enum value): <?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\

Deserialize xml into super class object with C#

本秂侑毒 提交于 2019-12-05 05:17:23
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> </Operator> <Operator> <value>4</value> </Operator> </Add> </Multiple> </xPlugin> </xPlugins> classes /

Deserialize XElement into Class(s)

你。 提交于 2019-12-04 22:35:07
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 riseAgainst.Album.Songs) { Console.WriteLine(string.Format("Song: {0}", s)); } Console.ReadLine(); } static

XML Deserialization of string elements with newlines in C#

不羁的心 提交于 2019-12-04 09:35:51
问题 I can't seem to figure out why this test doesn't pass The test is: given the following XML: <?xml version="1.0" encoding="utf-8"?> <foo> <account> 1234567890 </account> <deptCode> ABCXYZ </deptCode> </foo> and the following class: class Foo { [XmlElement(ElementName = "account", DataType = "normalizedString")] string account; [XmlElement(ElementName = "deptCode", DataType = "normalizedString"] string deptCode; } when that XML is deserialized with: XmlSerializer serializer = new XmlSerializer

Deserialize repeating XML elements in Simple 2.5.3 (Java)

那年仲夏 提交于 2019-12-04 05:26:52
问题 Let's say the following XML is given: <?xml version="1.0" encoding="UTF-8"?> <ResC> <Err text="Error text 1"/> <ConRes> <Err text="Error text 2"/> <ConList> <Err text="Error text 3"/> <Con> <Err text="Error text 4"/> </Con> </ConList> </ConRes> </ResC> As you can see the <Err> element may appear on every level of the XML. Using Simple I would like to deserialize this XML. So, I have created the following class: @Element(required=false) public class Err { @Attribute private String text; public

Pugixml - parse namespace with prefix mapping and without prefix mappig

社会主义新天地 提交于 2019-12-04 04:52:24
问题 I have a client application that parses xml responses that are sent from 2 different servers. I call them server A and server B. Server A responds to one of the request with a response as below: <?xml version="1.0" encoding="UTF-8"?> <D:multistatus xmlns:D="DAV:"> <D:response> <D:href>/T12.txt</D:href> <D:propstat> <D:prop> <local-modification-time xmlns="urn:abc.com:webdrive">1389692809</local-modification-time> </D:prop> <D:status>HTTP/1.1 200 OK</D:status> </D:propstat> </D:response> </D

What would cause this custom XML ModelBinder to not deserialize my XML POST?

独自空忆成欢 提交于 2019-12-04 04:47:56
问题 The Model public class SimpleUser { public string FirstName { get; set; } public string LastName { get; set; } public string UserName { get; set; } public int Role { get; set; } public bool isActive { get; set; } public string Groups { get; set; } } The BinderProvider public class SimpleUserProvider : IModelBinderProvider { public IModelBinder GetBinder(Type modelType) { var contentType = HttpContext.Current.Request.ContentType; if (string.Compare(contentType, @"text/xml", StringComparison

XML With SimpleXML Library - Performance on Android

你。 提交于 2019-12-04 00:28:52
I'm using the Simple XML library to process XML files in my Android application. These file can get quite big - around 1Mb, and can be nested pretty deeply, so they are fairly complex. When the app loads one of these files, via the Simple API, it can take up to 30sec to complete. Currently I am passing a FileInputStream into the [read(Class, InputStream)][2] method of Simple's Persister class. Effectively it just reads the XML nodes and maps the data to instances of my model objects, replicating the XML tree structure in memory. My question then is how do I improve the performance on Android?

XML deserialization generic method

丶灬走出姿态 提交于 2019-12-03 18:01:45
问题 I have next XML file: <Root> <Document> <Id>d639a54f-baca-11e1-8067-001fd09b1dfd</Id> <Balance>-24145</Balance> </Document> <Document> <Id>e3b3b4cd-bb8e-11e1-8067-001fd09b1dfd</Id> <Balance>0.28</Balance> </Document> </Root> I deserialize it to this class: [XmlRoot("Root", IsNullable = false)] public class DocBalanceCollection { [XmlElement("Document")] public List<DocBalanceItem> DocsBalanceItems = new List<DocBalanceItem>(); } where DocBalanceItem is: public class DocBalanceItem {

Best way to deserialize this XML into an object

六月ゝ 毕业季﹏ 提交于 2019-12-03 15:41:10
In other examples I've seen that are similar to mine, there is a root node, then an array node, and then a bunch of array items. My problem is, my root node is my array node, so examples I've seen don't seem to work for me, and I can't change the XML schema. Here's the XML: <articles> <article> <guid>7f6da9df-1a91-4e20-8b66-07ac7548dc47</guid> <order>1</order> <type>deal_abstract</type> <textType></textType> <id></id> <title>Abu Dhabi's IPIC Eyes Bond Sale After Cepsa Buy</title> <summary>Abu Dhabi's IPIC has appointed banks for a potential sterling and euro-denominated bond issue, a document