|
-
Jul 17th, 2007, 07:58 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] XML Node to Dataset
Hi guys! Is it posible to "Convert" the XML Node to Dataset? Thanks in advance!
-
Jul 17th, 2007, 10:23 PM
#2
Re: XML Node to Dataset
c# Code:
DataSet ds = new DataSet();
ds.ReadXml("path to my XML");
Done!
-
Aug 16th, 2007, 03:04 AM
#3
Thread Starter
Fanatic Member
Re: XML Node to Dataset
Thanks for that nmadd. But im trying to convert from a variable not from a file. Please see the code below.
Code:
public XmlNode FuncGetEvents()
{
XmlNode ndEventsItems;
try
{
string DateToday = DateTime.Now.ToString("yyyy-MM-dd");
lstServiceEvents.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
lstServiceEvents.PreAuthenticate = true;
XmlDocument xmlDoc = new System.Xml.XmlDocument();
XmlNode ndQuery = xmlDoc.CreateNode(XmlNodeType.Element, "Query", "");
XmlNode ndViewFields = xmlDoc.CreateNode(XmlNodeType.Element, "ViewFields", "");
XmlNode ndQueryOptions = xmlDoc.CreateNode(XmlNodeType.Element, "QueryOptions", "");
ndQuery.InnerXml = "<Where>" +
"<Geq><FieldRef Name='EventDate'/><Value Type='DateTime'>" + DateToday + "</Value></Geq>" +
"</Where>";
ndEventsItems = lstServiceEvents.GetListItems("Events", null, ndQuery, null, null, ndQueryOptions);
}
catch (Exception ex)
{
AlarmEventsEnable = false;
Common.LogException(ex, "FuncGetEvents");
}
return ndEventsItems;
}
What I want to do, if posible, is to convert the variable "ndEventsItems" from the code above to Dataset. By the way, the "GetListItems" method of "lstServiceEvents" returns XML Document. Please see sample return value below. (Value of OuterXml property)
<listitems
xmlns:s=\"uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882\"
xmlns:dt=\"uuid:C2F41010-65B3-11d1-A29F-00AA00C14882\"
xmlns:rs=\"urn:schemas-microsoft-com:rowset\"
xmlns:z=\"#RowsetSchema\"
xmlns=\"http://schemas.microsoft.com/sharepoint/soap/\"
>
<rs:data ItemCount=\"2\">
<z:row ows_fRecurrence=\"0\" ows_LinkTitle=\"BAC Meeting\" ows_EventDate=\"2007-08-15 09:00:00\" ows_Location=\"C. U. Del Rosario Hall B & C Power Training Center Bldg.\" ows_Alarm=\"2007-08-14 16:45:00\" ows_AlarmMemberChoice=\"ALL\" ows_Attachments=\"0\" ows_Attachment=\", \" ows_Title=\"BAC Meeting\" ows_ID=\"106\" ows_owshiddenversion=\"8\" />
<z:row ows_fRecurrence=\"0\" ows_LinkTitle=\"Test1\" ows_EventDate=\"2007-08-15 00:00:00\" ows_AlarmMemberChoice=\"ALL\" ows_Attachments=\"0\" ows_Attachment=\", \" ows_Title=\"Test1\" ows_ID=\"107\" ows_owshiddenversion=\"1\" />
</rs:data>
</listitems>
-
Aug 20th, 2007, 09:15 PM
#4
Thread Starter
Fanatic Member
Re: XML Node to Dataset
Problem Solved!...Just want to share...
Solution:
Code:
public DataSet FuncConvertToDataset(XmlNode xNode)
{
DataSet ds = new DataSet();
string tmp = string.Empty;
if ((xNode != null) && xNode.InnerXml.Length > 0)
{
XmlTextReader reader = new XmlTextReader(xNode.OuterXml, XmlNodeType.Element, null);
ds.ReadXml(reader);
}
return ds;
}
If you have Comments or Better suggestion please dont hesitate to post it here. Anyway, thanks a lot guys for the inputs...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|