473,394 Members | 1,674 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,394 software developers and data experts.

System.Array to XML

Hi.. Is there a way to convert a System.Array to XML...

If you know thanks very much...
if you don't... Please do not respond stupid things like " Yes -- many
ways."
Nov 12 '05 #1
5 12025
I suspect that you have got many stupid responses like that in the past,
perhaps that is because it is not a great question.
Your intentions are not clear. To take your question literally, the simple
answer is no. The is no TypeConverter or built in cast for converting from
System.Array to XML.

So now that we have established that your question is stupid, lets get on
with solving your problem.

The following information is needed:
1. What information does the array contain? Do not respond with stupid
things like "data"
2. Is there a particular xml structure that you would like to produce? Does
it need to conform to a schema?
3. How would you like the XML result presented? a string? a file? a stream?

Colin

"Abraham Lopez" <ab***********@hotmail.com> wrote in message
news:O6**************@TK2MSFTNGP12.phx.gbl...
Hi.. Is there a way to convert a System.Array to XML...

If you know thanks very much...
if you don't... Please do not respond stupid things like " Yes -- many
ways."

Nov 12 '05 #2
1. What information does the array contain? Do not respond with stupid
things like "data"
"DATA"

2. Is there a particular xml structure that you would like to produce?
"ANY ONE"

Does it need to conform to a schema?
"NO"

3. How would you like the XML result presented? a string? a file? a stream?
"ANY OF THEM"
"Colin Savage" <sa****@hotmail.com> escribió en el mensaje
news:br**********@ctb-nnrp2.saix.net...
I suspect that you have got many stupid responses like that in the past,
perhaps that is because it is not a great question.
Your intentions are not clear. To take your question literally, the simple
answer is no. The is no TypeConverter or built in cast for converting from
System.Array to XML.

So now that we have established that your question is stupid, lets get on
with solving your problem.

The following information is needed:
1. What information does the array contain? Do not respond with stupid
things like "data"
2. Is there a particular xml structure that you would like to produce? Does it need to conform to a schema?
3. How would you like the XML result presented? a string? a file? a stream?
Colin

"Abraham Lopez" <ab***********@hotmail.com> wrote in message
news:O6**************@TK2MSFTNGP12.phx.gbl...
Hi.. Is there a way to convert a System.Array to XML...

If you know thanks very much...
if you don't... Please do not respond stupid things like " Yes -- many
ways."


Nov 12 '05 #3

"Abraham Lopez" <ab***********@hotmail.com> wrote in message
news:O6**************@TK2MSFTNGP12.phx.gbl...
Hi.. Is there a way to convert a System.Array to XML...

If you know thanks very much...
if you don't... Please do not respond stupid things like " Yes -- many
ways."


The answer you got only reflects the question... :o)

Your question is so general, that it belongs to the same group as "Is there
a way to work with a computer"

Collin already pointed out some certain properties of your question (to
state it in a more neutral way, its lack of concreteness makes it not too
meaningful).

To the questions that Collin asked in order to make sense of your question,
I would also add the following:

Are you asking is it possible to represent *the object* System.Array as
an XML document or do you have in mind a particular instance of
System.Array?

What is the type of data contained in the array elements -- e.g. simple
values or other objects?

What names should be used for the elements of this xml document?

What should be the encoding used ?

Or maybe you want to embed the source code representation of the array
simply as a text node?
=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL
Nov 12 '05 #4
namespace Ionic {

public struct Fred {
public int A;
public string B;
public bool C;
}

class Driver {
static void Main(string[] args) {
System.Random rnd= new System.Random();
int n= rnd.Next(3)+4;

// the array
Fred[] f= new Fred[n];

// fill with junk data
for ( int i=0; i < n; i++) {
f[i]= new Fred();
f[i].A= rnd.Next(17);
f[i].B= new System.String((char)(rnd.Next(26)+65), rnd.Next(20)+10);
f[i].C= ((rnd.Next(10) % 2) == 0);
}

//Serialize
System.Xml.Serialization.XmlSerializer s = new
System.Xml.Serialization.XmlSerializer(typeof(Fred[]));
s.Serialize(System.Console.Out,f);

System.Console.WriteLine();
}
}
}
"Dimitre Novatchev" <dn********@yahoo.com> wrote in message
news:br************@ID-152440.news.uni-berlin.de...

"Abraham Lopez" <ab***********@hotmail.com> wrote in message
news:O6**************@TK2MSFTNGP12.phx.gbl...
Hi.. Is there a way to convert a System.Array to XML...

If you know thanks very much...
if you don't... Please do not respond stupid things like " Yes -- many
ways."
The answer you got only reflects the question... :o)

Your question is so general, that it belongs to the same group as "Is

there a way to work with a computer"

Collin already pointed out some certain properties of your question (to
state it in a more neutral way, its lack of concreteness makes it not too
meaningful).

To the questions that Collin asked in order to make sense of your question, I would also add the following:

Are you asking is it possible to represent *the object* System.Array as an XML document or do you have in mind a particular instance of
System.Array?

What is the type of data contained in the array elements -- e.g. simple values or other objects?

What names should be used for the elements of this xml document?

What should be the encoding used ?

Or maybe you want to embed the source code representation of the array
simply as a text node?
=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL

Nov 12 '05 #5
Yes, this is nice!

However, one has to know in advance the type of the elements of the array
and this is one of the not-answered questions by the OP.

I changed slightly your example and now it throws an exception.

In the code below I have an array of Object. The first element of the array
is a Fred instance, the rest are ints:

using System;
namespace Ionic
{

public struct Fred
{
public int A;
public string B;
public bool C;
}

class Driver
{
static void Main(string[] args)
{
System.Random rnd= new System.Random();
int n= rnd.Next(3)+4;

// the array
Object[] f= new Object[n];

Fred f1 = new Fred();
f[0]= f1;

f1.A= rnd.Next(17);
f1.B= new System.String((char)(rnd.Next(26)+65), rnd.Next(20)+10);
f1.C= ((rnd.Next(10) % 2) == 0);
// fill with junk data
for ( int i=1; i < n; i++)
{
f[i]= i;
}

//Serialize
try
{
System.Xml.Serialization.XmlSerializer s = new
System.Xml.Serialization.XmlSerializer(typeof(Obje ct[]));
s.Serialize(System.Console.Out,f);

System.Console.WriteLine();
}
catch(Exception e)
{
string s = e.Message;
System.Console.WriteLine(s);
}
}
}
}

What am I doing wrong?
=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL


"Dino Chiesa [Microsoft]" <di****@online.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
namespace Ionic {

public struct Fred {
public int A;
public string B;
public bool C;
}

class Driver {
static void Main(string[] args) {
System.Random rnd= new System.Random();
int n= rnd.Next(3)+4;

// the array
Fred[] f= new Fred[n];

// fill with junk data
for ( int i=0; i < n; i++) {
f[i]= new Fred();
f[i].A= rnd.Next(17);
f[i].B= new System.String((char)(rnd.Next(26)+65), rnd.Next(20)+10); f[i].C= ((rnd.Next(10) % 2) == 0);
}

//Serialize
System.Xml.Serialization.XmlSerializer s = new
System.Xml.Serialization.XmlSerializer(typeof(Fred[]));
s.Serialize(System.Console.Out,f);

System.Console.WriteLine();
}
}
}
"Dimitre Novatchev" <dn********@yahoo.com> wrote in message
news:br************@ID-152440.news.uni-berlin.de...

"Abraham Lopez" <ab***********@hotmail.com> wrote in message
news:O6**************@TK2MSFTNGP12.phx.gbl...
Hi.. Is there a way to convert a System.Array to XML...

If you know thanks very much...
if you don't... Please do not respond stupid things like " Yes -- many
ways."


The answer you got only reflects the question... :o)

Your question is so general, that it belongs to the same group as "Is

there
a way to work with a computer"

Collin already pointed out some certain properties of your question (to
state it in a more neutral way, its lack of concreteness makes it not too meaningful).

To the questions that Collin asked in order to make sense of your

question,
I would also add the following:

Are you asking is it possible to represent *the object* System.Array

as
an XML document or do you have in mind a particular instance of
System.Array?

What is the type of data contained in the array elements -- e.g.

simple
values or other objects?

What names should be used for the elements of this xml document?

What should be the encoding used ?

Or maybe you want to embed the source code representation of the array simply as a text node?
=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL



Nov 12 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

27
by: Trep | last post by:
Hi there! I've been having a lot of difficult trying to figure out a way to convert a terminated char array to a system::string for use in Visual C++ .NET 2003. This is necessary because I...
4
by: Joe Doyle | last post by:
I'm trying to do this- .... void method1(System.Array arr) { // happen to know all elements in arr are int's // this line throws an InvalidCastException int intArr = (int) arr; }
2
by: Chris | last post by:
Hi, the specs for System.Array are : MustInherit Public Class Array Implements ICloneable, IList, ICollection, IEnumerable but I can't use any of the functions presented by IList in my code ...
1
by: m830266 | last post by:
I'm trying to use the APAX serial I/O control (www.turbocontrol.com/AProZilla.htm) in a VB.NET project and I'm having trouble with its 'data received' events. The data is supplied by APAX as a...
5
by: Stacey Levine | last post by:
I have a webservice that I wanted to return an ArrayList..Well the service compiles and runs when I have the output defined as ArrayList, but the WSDL defines the output as an Object so I was...
2
by: stunt016 | last post by:
I have a program written in C# that handles communication between two pieces of software. My problem only deals with getting a text array from one program to this C# "Bridge". I can get the text...
3
by: clawton | last post by:
Hi All - I've got a 3rd party COM object that returns an array of bytes that are a TIFF image. After adding the reference to the com object to my solution the C# signature for the method is...
2
by: Fred Mellender | last post by:
I am trying to use reflection to output the fields (names and values) of an arbitrary object -- an object dump to a TreeView. It works pretty well, but I am having trouble with generic lists,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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...

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.