I don't see a way to use that suggestion with the parts that I have. The errors of interest are not going to be found by the default serializer; they are schema conformance errors, relating to a specific xsd, and not plain XML errors.
I have some data in Excel which represents structured lists to be imported into a SQL database in an XML format. I am not so familiar with the nuances of XML but I am pretty good with VBA. I need to generate an XML file that looks like this.
<?xmlversion="1.0"?><!DOCTYPExml><!--To use the dtd in an external file: <!DOCTYPE xml SYSTEM "filename.dtd">-->
-<transactionvaultname="Type in the name of the vault here"date="123459"type="import_lists"><!-- Just a list without links -->
-<listname="Materials"><itemitem_name="Ceramic"/><itemitem_name="Ferrous Metal"/><itemitem_name="Nonferrous Metal"/><itemitem_name="Superalloy"/></list><!-- A set of linked lists -->
-<listname="Ceramics"><itemitem_name="Boride"/><itemitem_name="Carbide"/><itemitem_name="Nitride"/><linklink_value="Ceramic"list_variable="Material Type"source_variable="My Material"/></list>
-<listname="Ferrous Metals"><itemitem_name="Stainless Steel"/><itemitem_name="Carbon Steel"/><itemitem_name="Tool Steel"/><linklink_value="Ferrous Metal"list_variable="Material Type"source_variable="My Material"/></list>
-<listname="Nonferrous Metals"><itemitem_name="Aluminium Alloy"/><itemitem_name="Copper Alloy"/><itemitem_name="Tin Alloy"/><linklink_value="Nonferrous Metal"list_variable="Material Type"source_variable="My Material"/></list>
-<listname="Superalloys"><itemitem_name="Cobalt Base"/><itemitem_name="Iron Base"/><itemitem_name="Nickel base"/><linklink_value="Superalloy"list_variable="Material Type"source_variable="My Material"/></list></transaction></transactions></xml>
I have the data in Excel and I would like to use VBA code similar to the below, but I am having a devil of a time getting it to output as shown above. When I change the tags to what I need in the sample output the result is just a mess. I am sure its my limited exposure to XML that has me stumbling. If someone could show me a sample set of the VBA that would output some of the above it would get me rolling again.
<?xmlversion="1.0"encoding="UTF-8"?><!-- Edited by XMLSpy --><catalog><example>
:20:FT13261793408907 N23B:CRED SA32A:130918USD111670,00
output must not be in a same line its must be as shown in the desired o/p
Hi all, I have already raised my question in different area of this forum. Please have a look at my question from the below link for more information. Could you please help me to generate xml structure with mutiple namespces. TIA.
I'd like to serialize an Objekt with XmlSerializer. The Objekt is a kind of treeview with lots of public properties like this:
Currently I have different kind of classes stored in the Instance objects, all inheriting from the same base class. If I want to serialize these, I need to tell the XmlSerializer in an XmlAttributeOverrides object about the different Instance object classes. I collect this information dynamically before starting the XmlSerializer.
Setting a breakpoint just before that I can check the Overrides object which looks like this:
Now here's my problem: I get a InvalidOperationException: "The type CTrModules.MDataSaveXML was not expected."
Looking through the Overrides above, CTrModules.MDataSaveXML was handed over to the serializer along with all other classes. All other classes can be serialized, but not this one. All classes have the Serializable attribute and are inheriting the same base class.
I'm at a loss here. Why is CTrModules.MDataSaveXML not expected?
I'm using C# in Visual Studio Espress 2013 for Windows Desktop, the target framework is .NET Framework 4.
Did you add the [XmlInclude(typeof(CTrModules.MDataSaveXML))]
attribute to the base class
I don't really want to go with that option, because then I have to remember to add such an include for any class I derive from the base class.
But I tried it just for test purposes: I get the same problem.
The option I chose to use is this one:
Bernhard Hiller wrote:
or pass an array of types to the constructor of the serializer?
I wrote a method to gather all types in an array and I pass this array to the serializer.
I set a breakpoint at the call of the serializer and inspected this array:
Guys, give me your thoughts on how you validate your xml at runtime. I recently fell into a drawn-out debug session where I couldn't see the problem with my xml file. I opened it in c#, read it, and checked for various attributes and what have you, adopting plan B that if I don't find an attribute I'll assume a default value.
The problem was I had an attribute called Recursion but I inadvertently spelt it Recursive, not the same thing!
I know I could validate the xml with an xsd file which sounds great in principal but is that the preferred way to validate your xml or do you do it the "safer" (word used very loosely) way by keeping all the literal names in your code and then issue warnings if things don't pass muster?
The xsd file itself could for any number of reasons be subject to an incorrect edit. I'd like to know which way you do things to ensure that when it comes to the usage, your xml is as clean to use as you can make it. Ideas?
If there is one thing more dangerous than getting between a bear and her cubs it's getting between my wife and her chocolate.
First time I have to do this. I know, where have I been the last 10 years...
Given a structure:
What is the best practice way to dump this in Xml format as well as read it? We're using rapidXml on this project, and what I've seen in existing code is line after line of sprint operations to format and then insert each tagged value into the Xml file. Pretty much the same thing trying to read the Xml back in.
My concern is that some of my structures are going to be changing day by day, and keeping the conversion code up to data is going to be tedious.
Anyone have a better way to do this, or is this just the nature of the beast?
<italic>You're going to tell me what I want to know, or I'm going to beat you to death in your own house.
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759