473,288 Members | 2,725 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,288 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 12020
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,...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.