Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / XML / February 2008

Tip: Looking for answers? Try searching our database.

storing a string into a xmlelement and vice versa

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
deepak - 08 Feb 2008 12:21 GMT
Hi All,

this is a string

"<SXPServerGetObjectsResult><Objects><Task><District Key="258627584">NL
KPN</District></Task></Objects></SXPServerGetObjectsResult>"

i want to store this into a xmlelement variable for further processing
this as xmlelement

How can i do it?
may u also tell me vicevers i.e. xmelement to string?
Any help would be appreciated by me.

Thanks,
Deepak
kr_deepak123@hotmail.com
kr_deepak123@yahoo.co.in
Martin Honnen - 08 Feb 2008 13:01 GMT
> this is a string
>
[quoted text clipped - 3 lines]
> i want to store this into a xmlelement variable for further processing
> this as xmlelement

There are various ways to achieve that, one is creating an
XmlDocumentFragment and set its InnerXml property e.g.
  Dim doc As New XmlDocument()
  Dim frag As XmlDocumentFragment = doc.CreateDocumentFragment()
  frag.InnerXml = yourString
  Dim element As XmlElement = CType(frag.FirstChild, XmlElement)

> may u also tell me vicevers i.e. xmelement to string?

  xmlNodeInstance.OuterXml
see
<URL:http://msdn2.microsoft.com/en-us/library/system.xml.xmlnode.outerxml.aspx>

Signature

    Martin Honnen --- MVP XML
    http://JavaScript.FAQTs.com/

Anthony Jones - 08 Feb 2008 13:06 GMT
> Hi All,
>
[quoted text clipped - 9 lines]
> may u also tell me vicevers i.e. xmelement to string?
> Any help would be appreciated by me.

You can use XmlDocuments LoadXml method and OuterXml property.

string sIn = @"<SXPServerGetObjectsResult><Objects>
<Task><District Key=""258627584"">NL
KPN</District></Task></Objects></SXPServerGetObjectsResult>";

XmlDocument dom = new XmlDocument();

dom.LoadXml(sIn);

//Manipulate XML using dom.documentElement

Console.WriteLine(dom.OuterXml);

Signature

Anthony Jones - MVP ASP/ASP.NET

deepak - 08 Feb 2008 16:42 GMT
yeah its working after using outer xmlproperty.
Thanks a lot Anthony and Martin...u really helped me  in crucial time..u
dont know that how much will be this thing be helpful for me and my
project....Thanks again...u can add me in hotmail or yahoo or mail me your id
on my mail.My ids are given below

-Deepak
kr_deepak123@hotmail.com
kr_deepak123@yahoo.co.in

> > Hi All,
> >
[quoted text clipped - 23 lines]
>
> Console.WriteLine(dom.OuterXml);

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.