473,402 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

VB - XML Serialization Arrays

I have an array of string that i want to serialize to an xml file. By default .net will serialize it something something similar to this

<ArrayOfStrings>
<string>Testing</string>
<string>Another Test</string>
<string>Last One</string>
</ArrayOfStrings>

Now, if you use the <XMLArrayElement()> method and pass in a string i know that i can change it from using <string></string> to whatever I want(item for example). But what i would like to do is remove the array open and closing tag from the set all together so my own output would just be something like:

<item>Testing</item>
<item>Another Test</item>
<item>Last One</item>

I know that this may create deserialization issues but thats not a problem, I just need it to format it like this. Any help would be greatly appreciated.
Sep 4 '08 #1
5 2055
Frinavale
9,735 Expert Mod 8TB
XML files have to have 1 root element...removing this will cause the XML to become invalid and so I don't think it will be easy to remove it.

Consider instead creating a serializable class that holds "items" instead of using an array.

-Frinny
Sep 5 '08 #2
thanks for the reply. I do have one root element and there are other items but I have a list of strings that have to be an array but I don't want tagged as a group in any way. Is there any way to accomplish this?
Sep 5 '08 #3
Frinavale
9,735 Expert Mod 8TB
thanks for the reply. I do have one root element and there are other items but I have a list of strings that have to be an array but I don't want tagged as a group in any way. Is there any way to accomplish this?

I don't think so.
There's a reason why your strings are grouped together...why not just leave them that way?
Sep 5 '08 #4
I'm using this as an easy way to output an xml response for another usage and it has to be formatted that way. The other program that is picking it up requires this.
Sep 5 '08 #5
Frinavale
9,735 Expert Mod 8TB
I'm using this as an easy way to output an xml response for another usage and it has to be formatted that way. The other program that is picking it up requires this.
Have you tried creating an Object that will result in being serialized the way you are describing?

-Frinny
Sep 5 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Franz | last post by:
Let me describe the flow of my program first. 1. Deserialize data from xml file. 2. Addition of "PersonType" class to the AllPersonalData. 3. Serialize data back to the xml file. My question is...
16
by: Bob Rock | last post by:
Hello, when serializing an array of elements of a class Classname using XmlSerializer.Serialize() I get an XML like the following: <?xml version="1.0"> <ArrayOfClassname> ....... ..........
3
by: Ice | last post by:
All - I'm pretty comfortable with simple XML serialization of objects. However I observed something the other day and I wanted to know if I solved it the right way. Basically if I have a...
4
by: hs | last post by:
Hi I am serializing a dataset using a binary formatter as follows: IFormatter formater = new BinaryFormatter(); formatter.Serialize(stream, ds); // ds=DataSet, stream=MemoryStream .... DataSet...
8
by: Pavils Jurjans | last post by:
Hello, I have been developing an Ajax-style framework for couple of years now. Now I am reworking some parts of it. The problem was that I used to use JSON for JavaScript value...
0
by: ronnotel | last post by:
I have integrated APIs from a third party into my framework. The third party is essentially a .Net wrapper on top of an existing set of C++ classes and structs. I want to pass-around objects in...
0
by: crazyone | last post by:
I've got a gaming framework i'm building and i want to save myself the trouble of reading and writting the complete game data to a custom file and load/save it to an XML file but i'm getting...
4
by: Sahar | last post by:
Hi there, I m trying to return an object (of my own written class) from a web service that contains jagged Arrays as public variables. Asp.Net is showing me the its serialized version on the...
11
by: William | last post by:
I'm looking for an example that would show how to serialize a c++ object at it's simplest w/o using any other api's. I have a class that I want to serialize and then pass to my obj-c class so I can...
10
by: aaragon | last post by:
Hello everyone, I've been trying to create a simple way to serialize C++ objects so I can send messages among different processors (using MPI). Something very simple is shown below: template...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.