473,320 Members | 2,088 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,320 software developers and data experts.

From XmlNode to string

hi

I got an XmlNode called xNode
Is there a way to convert it so it fits into a string ?
Nov 15 '05 #1
7 24099
Jeppe BS <hu************@hotmail.com> wrote:
I got an XmlNode called xNode
Is there a way to convert it so it fits into a string ?


Well what do you want from it in terms of a string representation?
There are various methods which convert it into different string
representations, but you'll need to know exactly what you want before
you can really pick one.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #2
Hi

Try using the xml propetery. This gives you the xml in a string.

Gary

"Jeppe BS" <hu************@hotmail.com> wrote in message
news:e1**************************@posting.google.c om...
hi

I got an XmlNode called xNode
Is there a way to convert it so it fits into a string ?

Nov 15 '05 #3
hmm weird
i started this thread from google groups and when i wanted to answer i
had to sign up for an account?? How did i t happen in the first place ??

Anyway
got this webmethod (using Web Matrix) and it should return a string. I
pick out the XmlNode i want and try to return it.
code

XmlNode personNode;
XmlNode root = personDB.DocumentElement;

personNode = root.SelectSingleNode("/person[navn='Jeppe']");

// can i do this ??
string wayout = personNode.OuterXml;

return wayout;


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #4
Jeppe Svendsen <hu************@hotmail.com> wrote:
Anyway
got this webmethod (using Web Matrix) and it should return a string. I
pick out the XmlNode i want and try to return it.
code

XmlNode personNode;
XmlNode root = personDB.DocumentElement;

personNode = root.SelectSingleNode("/person[navn='Jeppe']");

// can i do this ??
string wayout = personNode.OuterXml;

return wayout;


I'm sure you *can* do that - but whether or not it's the string you
*want* to return, I don't know. What are you passing this string to
afterwards? What format is it expected to be in?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #5
Jeppe,

You can not convert it so it fits in a string, so to speak, but you can
get the value from the XmlNode by using the Value property on the XmlNode
instance. Also, you can use the InnerXml and OuterXml properties to get the
of the node.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- nick(dot)paldino=at=exisconsulting<dot>com

"Jeppe BS" <hu************@hotmail.com> wrote in message
news:e1**************************@posting.google.c om...
hi

I got an XmlNode called xNode
Is there a way to convert it so it fits into a string ?

Nov 15 '05 #6

I'm sure you *can* do that - but whether or not it's the >string you
*want* to return, I don't know. What are you passing this >string to
afterwards? What format is it expected to be in?


Well a want a string so i chekck in it my browser if i find the node i
am seraching for.

Guess i could write it into a file, open the file, read like a string,
and return. But wouldnt that be a long way to fix it ??

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #7
Jeppe BS <an*******@devdex.com> wrote:
I'm sure you *can* do that - but whether or not it's the >string you
*want* to return, I don't know. What are you passing this >string to
afterwards? What format is it expected to be in?
Well a want a string so i chekck in it my browser if i find the node i
am seraching for.


Just any string? You could use any of the following properties:

OuterXml, InnerXml, Value, Name

(and that's just for starters). Those will each give different strings
though - if you're not sure which one of them you want, I suggest you
read the documentation for each of them and see which one sounds most
useful to you.
Guess i could write it into a file, open the file, read like a string,
and return. But wouldnt that be a long way to fix it ??


Yes it would.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #8

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

Similar topics

3
by: Mahesh Devjibhai Dhola | last post by:
Hi All, I want to make a custom class in c#, which extends System.Xml.XmlNode class of BCL. Now in custom class, I have implement abstract methods of XmlNode class also. Now when I am trying to...
5
by: Paul | last post by:
Here I have the definition of an XmlNode which is a property (PayPreference) on my Customer class containing an enum describing how the customer will pay. <PayPerference...
5
by: Mahesh Devjibhai Dhola | last post by:
Hi All, I want to make a custom class in c#, which extends System.Xml.XmlNode class of BCL. Now in custom class, I have implement abstract methods of XmlNode class also. Now when I am trying to...
3
by: melanieab | last post by:
Hi, I can't seem to get the syntax correct. I have an xmlnodelist full of elements called "file". Each file has an attribute called "ID". If I just want to get, say, the ID of the second file...
3
by: Mae | last post by:
Dear All, I have a problem here, I'm using C# Webform calling a webservices. The webservices return me a XMLnode, using this XMLnode I want to convert it to dataset so I can bind to the...
12
by: Whoever | last post by:
Hi, I'm trying to return an XmlDocument or XmlNode converted from a typed dataset. public XmlNode whatever() { MyTypedDataSet ds = new MyTypedDataSet(); return new XmlDataDocument(ds); }
1
by: Jeff Ditty | last post by:
Hello- I am looking for the best way to run different Xpath expressions from a web service, and return the appropriate XML data. The data source that the web service queries is an XML file,...
5
by: th3dude | last post by:
I've searched quite a bit for this one and i can't find any solid solution for what i'm doing here. Right now i'm geting an xml string from an API, creating an xml file, then read the file with...
5
by: Sharon | last post by:
How can I get the full XML path (as string) of a specific XmlNode ? -- Thanks Sharon
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...
1
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: 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)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.