xml-deserialization

Strange deserialization issue

孤人 提交于 2019-12-12 03:32:57
问题 I've created classes from XSD Schema using xsd.exe (also tried with xsd2code which had better results in a way that they worked immediately, and with xsd.exe I have to debug some errors). XSD Schema I've used can be found at http://www.landxml.org/schema/LandXML-1.2/LandXML-1.2.xsd , and sample file can be found at http://landxml.org/schema/LandXML-1.1/samples/AASHTO%20SDMS/MntnRoad.xml . My code for deserialization looks like: var mySerializer = new XmlSerializer(typeof (LandXML), new

xmlns namespace resilency

☆樱花仙子☆ 提交于 2019-12-12 02:33:55
问题 I receive data from a server as utf-8 encoded xml messages that look like <?xml version="1.0" encoding="utf-8"?> <Data namespace="http://example.com/data"> ... </Data> The noteworthy thing about the example is that the "namespace" qualifier should in reality be the "xmlns" qualifier specifying the default xml namespace. The code for serialization / deserialization was (auto-) generated from a schema definition file, and both the xsd as well as the documentation that came along with it pretty

Overriding incoming invalid datetime values in webservice

♀尐吖头ヾ 提交于 2019-12-12 01:22:02
问题 I'm currently writing a C# webservice that has to match an existing wsdl, and my webservice is called by a third party webservice (My webservice acts as a callback). However I'm being passed invalid values, and the third party webservice is unwilling to change their webservice. I'm getting: '2010-10-24 12:12:13' type strings in the xml as a DateTime, (which doesn't meet the spec as it has to be '2010-10-24T12:12:13') Is there any way to override the XML Serialization so that it still matches

xml content changed after serialization & deserialization want to pass in xml to map object

时间秒杀一切 提交于 2019-12-11 19:36:09
问题 Please help: What I need to do: I pass in an XML file from a browser bar, then try to map the data in the XML files to a object type in a class. There are many different objects types, so if I write classes for each serialization & deserialization, that would be too much work. I searched some code for serialization & deserialization and tried them, they compile, but many of the data are missing. My code for serialization & deserialization are here: string InputFilePath = FileUpload1

XML - Can not deserialize after serialize

萝らか妹 提交于 2019-12-11 16:51:10
问题 I create a list, save it as XML (with XmlSerializer) but I not success (although all web searches…) to deserialize. My entities are: public class basicTxtFile { public string filename; public string description; } public class fileTools { }; public class textboxTool : fileTools // text box { public string defaultText; public bool multiLine; public bool browseButton; }; public class comboboxTool : fileTools // combo box { public List<string> values = new List<string>(); }; // Must file, can

Error while deserializing XML in C#

回眸只為那壹抹淺笑 提交于 2019-12-11 15:04:56
问题 I have the following XML to serialize: <ArrayOfStockObject xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/LLL_server.Models"> <StockObject xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/" z:Id="i1"> <G_ArticleType z:Id="i2" i:type="ArtTypeBall"> <G_Descr>Weißer Fussball!</G_Descr> <G_Color>Weiß</G_Color> <G_Material>Leder</G_Material> <G_Radius>20</G_Radius> </G_ArticleType> <G_Code i:nil="true"/> <G_Place i:nil="true"/> <G

Deserialization XMl Error

让人想犯罪 __ 提交于 2019-12-11 10:45:37
问题 The serialization of a list doesn't face problems. Creation of the XML File: XmlDocument toolConfig = new XmlDocument(); XmlNode myRoot; myRoot = toolConfig.CreateElement("Tool"); toolConfig.AppendChild(myRoot); toolConfig.Save(@userConfigurePath + "\\config.xml"); After the serialization the xml file looks like this: <?xml version="1.0" encoding="utf-8"?> <Tools xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Tool> <Name>test</Name> <Path

Deserializing nested lists with XmlSerializer

China☆狼群 提交于 2019-12-11 05:04:14
问题 I have a problem deserializing a list inside a list of elements with this structure: <Level> <Stage> <Sets> <Set></Set> <Set></Set> </Sets> </Stage> <Stage> <Sets> <Set></Set> <Set></Set> </Sets> </Stage> </Level> My current code is this: public class Level{ [XmlElement(ElementName="Stage")] public List<Stage> Stages = new List<Stage>(); } public class Stage{ [XmlAttribute("label")] public string label {get;set;} [XmlAttribute("pack")] public string pack {get;set;} [XmlElement(ElementName =

XmlException: Document element did not appear - line 1, position 1

浪尽此生 提交于 2019-12-11 04:09:16
问题 I'm tring to deserialize a xml string, but for some reason I'm getting the error stated in the title. This is the code I'm deserializing from: public void recieveObject<T>(ref T t){ XmlSerializer xs = new XmlSerializer(typeof(T)); Debug.Log("Waiting for client"); byte[] recievedData = udpc.Receive(ref recieveFromEndPoint); if(recievedData.Length > 0){ string xmlStr = System.Text.Encoding.UTF8.GetString(recievedData, 0, recievedData.Length); //xmlStr = xmlStr.Replace("\r","").Replace("\n", "")

Deserialization of nullable value with xsd.exe generated class

感情迁移 提交于 2019-12-11 03:26:32
问题 Nullable value with xsd.exe generated class answers why the generated class has a *Specified field and property, and how it's used for serializing an XML file, but how am I able to set this value during deserialization ? I have a generated class as defined below: /// <remarks/> [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.33440")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")]