473,799 Members | 2,779 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 12050
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******** ******@TK2MSFTN GP12.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******** ******@TK2MSFTN GP12.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******** ******@TK2MSFTN GP12.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.Seri alization.XmlSe rializer s = new
System.Xml.Seri alization.XmlSe rializer(typeof (Fred[]));
s.Serialize(Sys tem.Console.Out ,f);

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

"Abraham Lopez" <ab***********@ hotmail.com> wrote in message
news:O6******** ******@TK2MSFTN GP12.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.Seri alization.XmlSe rializer s = new
System.Xml.Seri alization.XmlSe rializer(typeof (Object[]));
s.Serialize(Sys tem.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******** ********@TK2MSF TNGP09.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.Seri alization.XmlSe rializer s = new
System.Xml.Seri alization.XmlSe rializer(typeof (Fred[]));
s.Serialize(Sys tem.Console.Out ,f);

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

"Abraham Lopez" <ab***********@ hotmail.com> wrote in message
news:O6******** ******@TK2MSFTN GP12.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
51736
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 have some legcay C code that needs to process a string taken from a textbox, then I need to re-display the string as the textbox->Text. I easily found how to convert from system::string to char but I can't figure out how to go the other way!!
4
2189
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
2740
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 Dim numbers As System.Array
1
3772
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 variant which appears to VB.NET as a System.Object. I want to convert this to a System.Array so that I can iterate over its elements. The VB6 usage is described at www.turbocontrol.com/TechTips/20020426.htm. If I try something similar in...
5
19600
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 having a problem in the calling program. I searched online and found suggestions that I return an Array instead so I modified my code (below) to return an Array instead of an ArrayList. Now I get the message when I try to run just my webservice...
2
8748
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 array to the bridge, where it is received as a system.object. My problem is casting this system.object to a string array. The code I'm using is below. System.Array advArgs = args as System.Array; //creates array for parameters being...
3
5463
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 something like this: System.Array Item.GetContent(); I need to save the bytes to a file that will be the tiff file...so when I
2
6171
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, like List<char>. What I have working is : Type type = newObj.GetType(); //newObj is what I'm trying to dump
0
9541
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10482
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10251
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10225
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10027
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9072
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7564
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6805
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4139
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.