How to Read XElement contents containing Sharepoint List Structure? - c#

I want to bind the MultipleCheckbox items from Choice Column of sharepoint List to asp.net CheckBoxListItem using c#.
I am retriving information of List using XELEMENT as:
In .cs file:
XElement listStructure;
listStructure = proxy.GetList("WebsiteSubscriber");
here am getting XML as:
<List DocTemplateUrl="" DefaultViewUrl="/Lists/WebsiteSubscriber/AllItems.aspx" MobileDefaultViewUrl="" ID="{2C8A80EA-38C5-48F7-9D7D-400D445A5E64}" Title="WebsiteSubscriber" Description="" ImageUrl="/_layouts/images/itgen.png" Name="{2C8A80EA-38C5-48F7-9D7D-400D445A5E64}" BaseType="0" FeatureId="00bfea71-de22-43b2-a848-c05709900100" ServerTemplate="100" Created="20130417 02:18:11" Modified="20130424 09:27:11" LastDeleted="20130419 04:46:25" Version="5" Direction="none" ThumbnailSize="" WebImageWidth="" WebImageHeight="" Flags="545263616" ItemCount="13" AnonymousPermMask="0" RootFolder="/Lists/WebsiteSubscriber" ReadSecurity="1" WriteSecurity="1" Author="8" EventSinkAssembly="" EventSinkClass="" EventSinkData="" EmailAlias="" WebFullUrl="/" WebId="198e057a-38e8-410a-8358-ed95f77d18ea" SendToLocation="" ScopeId="e2cbf2fd-93e4-408d-bd4e-320321734b8c" MajorVersionLimit="0" MajorWithMinorVersionsLimit="0" WorkFlowId="" HasUniqueScopes="False" NoThrottleListOperations="False" HasRelatedLists="" AllowDeletion="True" AllowMultiResponses="False" EnableAttachments="True" EnableModeration="False" EnableVersioning="False" HasExternalDataSource="False" Hidden="False" MultipleDataList="False" Ordered="False" ShowUser="True" EnablePeopleSelector="False" EnableResourceSelector="False" EnableMinorVersion="False" RequireCheckout="False" ThrottleListOperations="False" ExcludeFromOfflineClient="False" EnableFolderCreation="False" IrmEnabled="False" IsApplicationList="False" PreserveEmptyValues="False" StrictTypeCoercion="False" EnforceDataValidation="False" MaxItemsPerThrottledOperation="100000" xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<Fields>
<Field ID="{03e45e84-1992-4d42-9116-26f756012634}" RowOrdinal="0" Type="ContentTypeId" Sealed="TRUE" ReadOnly="TRUE" Hidden="TRUE" DisplayName="Content Type ID" Name="ContentTypeId" DisplaceOnUpgrade="TRUE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="ContentTypeId" ColName="tp_ContentTypeId" FromBaseType="TRUE" />
<Field ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Name="Title" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Title" Group="Base Columns" Type="Text" DisplayName="Title" Required="FALSE" FromBaseType="TRUE" EnforceUniqueValues="FALSE" Indexed="FALSE" MaxLength="255" Version="1" ColName="nvarchar1" RowOrdinal="0" />
<Field ID="{34ad21eb-75bd-4544-8c73-0e08330291fe}" ReadOnly="TRUE" Type="Note" Name="_ModerationComments" DisplayName="Approver Comments" Hidden="TRUE" CanToggleHidden="TRUE" Filterable="FALSE" Sortable="FALSE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="_ModerationComments" FromBaseType="TRUE" ColName="ntext1" />
<Field ID="{bc91a437-52e7-49e1-8c4e-4698904b2b6d}" ReadOnly="TRUE" Type="Computed" Name="LinkTitleNoMenu" DisplayName="Title" Dir="" DisplayNameSrcField="Title" AuthoringInfo="(linked to item)" EnableLookup="TRUE" ListItemMenuAllowed="Prohibited" LinkToItemAllowed="Prohibited" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="LinkTitleNoMenu" FromBaseType="TRUE">
<FieldRefs>
<FieldRef Name="Title" />
<FieldRef Name="LinkFilenameNoMenu" />
</FieldRefs>
<DisplayPattern>
<IfEqual>
<Expr1>
<LookupColumn Name="FSObjType" />
</Expr1>
<Expr2>1</Expr2>
<Then>
<Field Name="LinkFilenameNoMenu" />
</Then>
<Else>
<HTML><![CDATA[<a onfocus="OnLink(this)" href="]]></HTML>
<URL />
<HTML><![CDATA[" onclick="EditLink2(this,]]></HTML>
<Counter Type="View" />
<HTML><![CDATA[);return false;" target="_self">]]></HTML>
<Column HTMLEncode="TRUE" Name="Title" Default="(no title)" />
<IfEqual>
<Expr1>
<GetVar Name="ShowAccessibleIcon" />
</Expr1>
<Expr2>1</Expr2>
<Then>
<HTML><![CDATA[<img src="/_layouts/images/blank.gif" class="ms-hidden" border="0" width="1" height="1" alt="Use SHIFT+ENTER to open the menu (new window)."/>]]></HTML>
</Then>
</IfEqual>
<HTML><![CDATA[</a>]]></HTML>
<IfNew>
<HTML><![CDATA[<img src="/_layouts/1033/images/new.gif" alt="]]></HTML>
<HTML>New</HTML>
<HTML><![CDATA[" class="ms-newgif" />]]></HTML>
</IfNew>
</Else>
</IfEqual>
</DisplayPattern>
</Field>
<Field ID="{82642ec8-ef9b-478f-acf9-31f7d45fbc31}" ReadOnly="TRUE" Type="Computed" Name="LinkTitle" DisplayName="Title" DisplayNameSrcField="Title" ClassInfo="Menu" AuthoringInfo="(linked to item with edit menu)" ListItemMenuAllowed="Required" LinkToItemAllowed="Prohibited" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="LinkTitle" FromBaseType="TRUE">
<FieldRefs>
<FieldRef Name="Title" />
<FieldRef Name="LinkTitleNoMenu" />
<FieldRef Name="_EditMenuTableStart2" />
<FieldRef Name="_EditMenuTableEnd" />
</FieldRefs>
<DisplayPattern>
<FieldSwitch>
<Expr>
<GetVar Name="FreeForm" />
</Expr>
<Case Value="TRUE">
<Field Name="LinkTitleNoMenu" />
</Case>
<Default>
<Switch>
<Expr>
<GetVar Name="MasterVersion" />
</Expr>
<Case Value="4">
<HTML><![CDATA[<div class="ms-vb itx" onmouseover="OnItem(this)" CTXName="ctx]]></HTML>
<Field Name="_EditMenuTableStart2" />
<HTML><![CDATA[">]]></HTML>
<Field Name="LinkTitleNoMenu" />
<HTML><![CDATA[</div>]]></HTML>
<HTML><![CDATA[<div class="s4-ctx" onmouseover="OnChildItem(this.parentNode); return false;">]]></HTML>
<HTML><![CDATA[<span> </span>]]></HTML>
<HTML><![CDATA[<a onfocus="OnChildItem(this.parentNode.parentNode); return false;" onclick="PopMenuFromChevron(event); return false;" href="javascript:;" title="Open Menu"></a>]]></HTML>
<HTML><![CDATA[<span> </span>]]></HTML>
<HTML><![CDATA[</div>]]></HTML>
</Case>
<Default>
<HTML><![CDATA[<table height="100%" cellspacing="0" class="ms-unselectedtitle itx" onmouseover="OnItem(this)" CTXName="ctx]]></HTML>
<Field Name="_EditMenuTableStart2" />
<HTML><![CDATA["><tr><td width="100%" class="ms-vb">]]></HTML>
<SetVar Name="ShowAccessibleIcon" Value="1" />
<Field Name="LinkTitleNoMenu" />
<SetVar Name="ShowAccessibleIcon" Value="0" />
<HTML><![CDATA[</td><td><img src="/_layouts/images/blank.gif" width="13" style="visibility:hidden" alt=""/></td></tr></table>]]></HTML>
</Default>
</Switch>
</Default>
</FieldSwitch>
</DisplayPattern>
</Field>
<Field ID="{5f190d91-3dbc-4489-9878-3c092caf35b6}" Hidden="TRUE" ReadOnly="TRUE" Type="Computed" Name="LinkTitle2" DisplayName="Title" DisplayNameSrcField="Title" ClassInfo="Menu" AuthoringInfo="(linked to item with edit menu) (old)" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="LinkTitle2" FromBaseType="TRUE">
<FieldRefs>
<FieldRef Name="Title" />
<FieldRef Name="LinkTitleNoMenu" />
<FieldRef Name="_EditMenuTableStart" />
<FieldRef Name="_EditMenuTableEnd" />
</FieldRefs>
<DisplayPattern>
<FieldSwitch>
<Expr>
<GetVar Name="FreeForm" />
</Expr>
<Case Value="TRUE">
<Field Name="LinkTitleNoMenu" />
</Case>
<Default>
<Field Name="_EditMenuTableStart" />
<SetVar Name="ShowAccessibleIcon" Value="1" />
<Field Name="LinkTitleNoMenu" />
<SetVar Name="ShowAccessibleIcon" Value="0" />
<Field Name="_EditMenuTableEnd" />
</Default>
</FieldSwitch>
</DisplayPattern>
</Field>
<Field ID="{39360f11-34cf-4356-9945-25c44e68dade}" ReadOnly="TRUE" Hidden="TRUE" Type="Text" Name="File_x0020_Type" DisplaceOnUpgrade="TRUE" DisplayName="File Type" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="File_x0020_Type" FromBaseType="TRUE" ColName="nvarchar2" />
<Field Type="Text" DisplayName="Email" Required="FALSE" EnforceUniqueValues="FALSE" Indexed="FALSE" MaxLength="255" ID="{bf605e59-6807-47de-87ac-617b2c8df00b}" SourceID="{2c8a80ea-38c5-48f7-9d7d-400d445a5e64}" StaticName="Email" Name="Email" ColName="nvarchar3" RowOrdinal="0" />
<Field Type="MultiChoice" DisplayName="Area" Required="FALSE" EnforceUniqueValues="FALSE" Indexed="FALSE" FillInChoice="FALSE" ID="{16cc1615-a490-44de-a870-c7ebe603e2cc}" SourceID="{2c8a80ea-38c5-48f7-9d7d-400d445a5e64}" StaticName="Area" Name="Area" ColName="ntext2" RowOrdinal="0">
<Default>Articles</Default>
**<CHOICES>
<CHOICE>Articles</CHOICE>
<CHOICE>Websites</CHOICE>
<CHOICE>Books</CHOICE>
</CHOICES>**
</Field>
<Field ID="{1d22ea11-1e32-424e-89ab-9fedbadb6ce1}" ColName="tp_ID" RowOrdinal="0" ReadOnly="TRUE" Type="Counter" Name="ID" PrimaryKey="TRUE" DisplayName="ID" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="ID" FromBaseType="TRUE" />
<Field ID="{c042a256-787d-4a6f-8a8a-cf6ab767f12d}" Type="Computed" DisplayName="Content Type" Name="ContentType" DisplaceOnUpgrade="TRUE" RenderXMLUsingPattern="TRUE" Sortable="FALSE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="ContentType" Group="_Hidden" PITarget="MicrosoftWindowsSharePointServices" PIAttribute="ContentTypeID" FromBaseType="TRUE">
I want to get above values following from XML.
<CHOICES>
<CHOICE>Articles</CHOICE>
<CHOICE>Websites</CHOICE>
<CHOICE>Books</CHOICE>
</CHOICES>

Provided you fix your XML, this does what you want:
var choices = (from n in xml.Descendants()
where n.Name.LocalName == "CHOICES"
select new
{
CHOICES = n.Elements().Select(x => x.Value).ToList()
}).ToList();
Will give you a list of the anonymous type CHOICES elements that contain your CHOICE element values. Example output:
Edit
See comments:
var choices = (from n in xml.Descendants()
where n.Name.LocalName == "CHOICE"
select n.Value).ToList();
This will return a list of the following string values:
Articles
Websites
Books
0;#Approved
1;#Rejected
2;#Pending
3;#Draft
4;#Scheduled

Related

Using C#, how can we pull attribute values from an XML Schema file and output that onto a CSV file?

I am trying to pull the attribute values for each of the element, that is in this XMl Schema file(XML below). I want the attribute values for the following: type, label, CompTypes, readonly, hidden, and required.
For example, here is one of the elements in the XML file:
<element type="xpowercomponent_FeaturedTiles" UID="40204fc9b5424b349e03134d777d29bc" label="Featured Tiles" readonly="false" hidden="false" default="" required="false" Component="" CompTypes="ThemedTileSetComponent;ThemedTileSetElectedComponent;" AutoEmbed="" WrappedUp="" AllowWrappingChange="" />
The expected result for this element should be:
xpowercomponent_FeaturedTiles, Featured Tiles, ThemedTileSetComponent,
ThemedTileSetElectedComponent, readonly="false", hidden="false",
required="false"
I have started a C# app to get this information, however it is not getting all the information properly. Could you please take a look at the code, and see how this can be fixed or improved? Is there a better way of approaching this, maybe LINQ? The ultimate goal is to then output these attribute values/data in a CSV file.
C#
class Program
{
static void Main(string[] args)
{
Parse();
}
public static void Parse()
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(#"D:\New Text Document.xml");
var captureElements = new List<CustomElements>();
var xdocument = xmlDoc.ToXDocument();
foreach (var element in xdocument.Elements())
{
foreach (var node in element.Elements()) //childs...
{
if (node.Name.LocalName.Equals("ElementType"))
{
foreach (var scopeNode in node.Elements())
{
if (scopeNode.Name.LocalName.Equals("element"))
{
var xml = XElement.Parse(scopeNode.ToString());
var customElement = new CustomElements();
customElement.Type = xml.Attribute("type")?.Value;
customElement.Label = xml.Attribute("label")?.Value;
customElement.CompTypes = xml.Attribute("CompTypes")?.Value;
customElement.Readonly = xml.Attribute("readonly")?.Value;
customElement.Hidden = xml.Attribute("hidden")?.Value;
customElement.Require = xml.Attribute("required")?.Value;
captureElements.Add(customElement);
}
}
}
}
}
}
}
public static class DocumentExtensions
{
public static XmlDocument ToXmlDocument(this XDocument xDocument)
{
var xmlDocument = new XmlDocument();
using (var xmlReader = xDocument.CreateReader())
{
xmlDocument.Load(xmlReader);
}
return xmlDocument;
}
public static XDocument ToXDocument(this XmlDocument xmlDocument)
{
using (var nodeReader = new XmlNodeReader(xmlDocument))
{
nodeReader.MoveToContent();
return XDocument.Load(nodeReader);
}
}
}
public class CustomElements
{
public string Type { get; set; }
public string Label { get; set; }
public string CompTypes { get; set; }
public string Readonly { get; set; }
public string Hidden { get; set; }
public string Require { get; set; }
}
Full XML Schema file:
<Schema xmlns:dt="urn:schemas-microsoft-com:datatypes" name="TopTier" xmlns="urn:schemas-microsoft-com:xml-data">
<AttributeType name="ID" dt:type="id" required="yes" />
<AttributeType name="Name" dt:type="string" required="yes" />
<AttributeType name="UniqueID" dt:type="int" default="schemas/107" />
<AttributeType name="Icon" dt:type="int" default="2" />
<AttributeType name="FriendlyName" dt:type="string" default="Top Tier" />
<AttributeType name="SS" dt:type="boolean" default="true" />
<AttributeType name="DSS" dt:type="boolean" default="true" />
<AttributeType name="ViewName" dt:type="" default="" />
<AttributeType name="DefaultCategorization" dt:type="string" default="" />
<AttributeType name="Version" dt:type="int" default="9" />
<ElementType name="Exports" content="textOnly" />
<ElementType name="Title" dt:type="string" content="textOnly" />
<ElementType name="Excerpt" dt:type="string" content="textOnly">
<description>This info is used to display on pages that link to this page.</description>
</ElementType>
<ElementType name="ThumbnailImage" dt:type="imagefile" content="textOnly">
<description>Thumbnail dimension should be 75 x 75 pixels.</description>
</ElementType>
<ElementType name="xhtml_BodyCopy" content="textOnly" />
<ElementType name="xpowerlist_LeftSidebarComponentsOverride" content="eltOnly" />
<ElementType name="xpowercomponent_LeftSidebarComponent" content="eltOnly" />
<ElementType name="xpowercomponent_FeaturedTiles" content="eltOnly" />
<ElementType name="SecondaryTitle" dt:type="string" content="textOnly" />
<ElementType name="xpowerlist_SecondaryComponentList" content="eltOnly" />
<ElementType name="xpowercomponent_SecondaryItem" content="eltOnly" />
<ElementType name="xpowergroupstart_SEOGroup" content="eltOnly">
<description>Search Engine Optimization Group</description>
</ElementType>
<ElementType name="BrowserTitle" dt:type="string" content="textOnly" />
<ElementType name="MetaDescription" dt:type="string" content="textOnly" />
<ElementType name="NoIndex" dt:type="boolean" content="textOnly" />
<ElementType name="NoFollow" dt:type="boolean" content="textOnly" />
<ElementType name="NoODP" dt:type="boolean" content="textOnly" />
<ElementType name="Priority" dt:type="enumeration" values="0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0" content="textOnly" />
<ElementType name="PublishDate" dt:type="localdate" content="textOnly" />
<ElementType name="xpowergroupend_" content="eltOnly" />
<ElementType name="xpowernavigation_BreadcrumbNavigation" content="eltOnly" />
<ElementType name="xpowercomponent_SectionControl" content="eltOnly" />
<ElementType name="TopTier" content="eltOnly" order="seq">
<attribute type="ID" />
<attribute type="Name" />
<element type="Title" UID="2bbcb2816ba743e2bd935d526f47d688" label="Title" readonly="false" hidden="false" default="" required="true" />
<element type="Excerpt" UID="2ac3ade7d9c34cae8a7f304d9754db86" label="Excerpt" readonly="false" hidden="false" default="" required="true" />
<element type="ThumbnailImage" UID="f4940dbfe27f4783a97c356f3ba0f959" label="Thumbnail Image" readonly="false" hidden="false" default="" required="false" Expanded="false" Width="" Height="" Border="" HSpace="" VSpace="" Alignment="" AlternateText="" />
<element type="xhtml_BodyCopy" UID="055d4709ffb24402a14f9d13af417401" label="Body Copy" readonly="false" hidden="false" default="" required="false" Height="" />
<element type="xpowerlist_LeftSidebarComponentsOverride" UID="1d281fa780b6419089c52913640ade93" label="Left Sidebar Components Override" readonly="false" hidden="false" default="" required="false" Enclosed="" AllowEnclosureChange="" List="xpowercomponent_LeftSidebarComponent" Component="" CompTypes="" AutoEmbed="" WrappedUp="" AllowWrappingChange="" />
<element type="xpowercomponent_FeaturedTiles" UID="40204fc9b5424b349e03134d777d29bc" label="Featured Tiles" readonly="false" hidden="false" default="" required="false" Component="" CompTypes="ThemedTileSetComponent;ThemedTileSetElectedComponent;" AutoEmbed="" WrappedUp="" AllowWrappingChange="" />
<element type="SecondaryTitle" UID="3d00fbe341ff4f2481c6199deb046997" label="Secondary Title" readonly="false" hidden="false" default="" required="false" />
<element type="xpowerlist_SecondaryComponentList" UID="3bc6293a826a4f2081dca1c5e1415978" label="Secondary Component List" readonly="false" hidden="false" default="" required="false" Enclosed="" AllowEnclosureChange="" List="xpowercomponent_SecondaryItem" Component="" CompTypes="TaxonomyTileComponent;ServiceComponent;ContactComponent;TitledCollection" AutoEmbed="" WrappedUp="" AllowWrappingChange="" />
<element type="xpowergroupstart_SEOGroup" UID="bf312bbd47d74c758d13695b8fa011c0" label="SEO Group" readonly="false" hidden="true" default="" required="false" Enclosed="" AllowEnclosureChange="" />
<element type="BrowserTitle" UID="c777f36e6f094b50a04692d3bfef387e" label="Browser Title" readonly="false" hidden="false" default="" required="false" />
<element type="MetaDescription" UID="05bab416415541beb05e90b94f7e5248" label="Meta Description" readonly="false" hidden="false" default="" required="false" />
<element type="NoIndex" UID="e224c1a3aaa846d9b19579d59d9b1af7" label="No Index" readonly="false" hidden="false" default="" required="false" />
<element type="NoFollow" UID="b40ae068c0d749c4bb8ecd589388bb1b" label="No Follow" readonly="false" hidden="false" default="" required="false" />
<element type="NoODP" UID="2557027d711d41c3b3ccbd3aab4650dd" label="No ODP" readonly="false" hidden="false" default="" required="false" />
<element type="Priority" UID="f49eec4e94864e03aedbd0e2be6a2822" label="Priority" readonly="false" hidden="false" default="" required="false" values="0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0" />
<element type="PublishDate" UID="5fdba65915744addb710631476822112" label="Publish Date" readonly="true" hidden="true" default="" required="false" />
<element type="xpowergroupend_" />
<element type="xpowernavigation_BreadcrumbNavigation" UID="140b1582e50e4a098e190942980bd728" label="Breadcrumb Navigation" readonly="false" hidden="true" default="" required="true" Expanded="false" Navigation="Ancestors" GenerationOrder="down" StartPage="x5" MaxNodes="" MaxDepth="" Query="">
<element type="Exports" default="" />
</element>
<element type="xpowercomponent_SectionControl" UID="56564fa9c2bd4e9ba44a417960146376" label="SectionControl" readonly="false" hidden="true" default="" required="true" Component="" CompTypes="SectionControl" AutoEmbed="" WrappedUp="" AllowWrappingChange="" />
</ElementType>
</Schema>
you can use System.Xml.Linq to get all the elements and the required attributes as below
XDocument document = XDocument.Load(#"D:\New Text Document.xml");
var eleCollection = document.Elements("element");
foreach (var element in eleCollection)
{
var type = element.Attribute("Type").Value;
}
This is easiest way one can use for loops on nodes to get the information in each node.
use node.ChildNodes property to get the chilenodes.
XmlDocument doc = new XmlDocument();
doc.Load("filepath");
//Here Path could be- "//ElementType" ---> this will give all nodes with name ElementType
XmlNodeList nodes= doc.SelectNodes("//give path of nodes you want attributes for");
foreach (XmlNode node in nodes)
{
//Assuming you want information of element tags
foreach (XmlNode child in node.ChildNodes)
{
string name= node.Attributes["type"].Value;
string name= node.Attributes["label"].Value;
}
}

Bind XML nested node Data into Repeater Control in ASP.NET

I have consume openweathermap API in xml format. In this XML data node are nested and unordered. I don't know how to bind data in repeater control.
Here is my C# code
using System.Net;
protected void GetWeatherInfo()
{
string appId = "API KEY";
string url = string.Format("http://api.openweathermap.org/data/2.5/forecast/daily?q=London&units=metric&mode=xml&cnt=2&APPID={0}", appId);
using (WebClient client = new WebClient())
{
string xmlData= client.DownloadString(url);
RepDetails.DataSource = xmlData;
RepDetails.DataBind();
}
}
Coming data from url
<weatherdata>
- <location>
<name>London</name>
<type />
<country>GB</country>
<timezone />
<location altitude="0" latitude="51.50853" longitude="-0.12574" geobase="geonames" geobaseid="2643743" />
</location>
<credit />
- <meta>
<lastupdate />
<calctime>0.0278</calctime>
<nextupdate />
</meta>
<sun rise="2015-12-16T08:00:32" set="2015-12-16T15:51:44" />
- <forecast>
- <time day="2015-12-16">
<symbol number="500" name="light rain" var="10d" />
<precipitation value="1.22" type="rain" />
<windDirection deg="250" code="WSW" name="West-southwest" />
<windSpeed mps="8.54" name="Fresh Breeze" />
<temperature day="13.11" min="12.09" max="13.2" night="12.22" eve="13.02" morn="12.63" />
<pressure unit="hPa" value="1023.73" />
<humidity value="94" unit="%" />
<clouds value="broken clouds" all="64" unit="%" />
</time>
- <time day="2015-12-17">
<symbol number="500" name="light rain" var="10d" />
<precipitation value="0.5" type="rain" />
<windDirection deg="199" code="SSW" name="South-southwest" />
<windSpeed mps="7.17" name="Moderate breeze" />
<temperature day="12.86" min="11.16" max="12.87" night="11.16" eve="12.48" morn="11.61" />
<pressure unit="hPa" value="1019.9" />
<humidity value="89" unit="%" />
<clouds value="broken clouds" all="68" unit="%" />
</time>
</forecast>
</weatherdata>
So, according to my requirement i need sun and time node data but i don't know how to manage relationship between parent and child node data in repeater control.
<itemTemplate>
<asp:Label ID="lblDate" runat="server" Text='<%#Eval("sun.rise") %>' Font-Bold="true" />
<asp:Label ID="lblComment" runat="server" Text='<%#Eval("time.temprature.day") %>' />
</itemTemplate>

XML C# XPath - Network Packets

I am currently working on trying to packet filter using XML C# and XPath. The aim is to draw out each unique IP source address and see what IP destinations it has been talking to.
The aim is to view, using a form, the Source and a list of the Destinations either using a list box or property grid.
public void LoadPackets()
{
var xmlDoc2 = new XmlDocument();
xmlDoc2.Load("Packets.xml");
foreach (XmlNode packet in xmlDoc2.DocumentElement)
{
var node = xmlDoc2.SelectSingleNode("pdml/packet/proto/field[#name='ip.src']/#show");
ipsrc = node.Value;
var node2 = xmlDoc2.SelectSingleNode("pdml/packet/proto/field[#name='ip.dst']/#show");
string ipdst = node2.Value;
list.Items.Add(ipsrc);
list.Items.Add(ipdst);
}
}
This currently finds an IP source and destination but repeats the same one whilst adding it to the list box. There are different IP sources and destinations that are not being added.
Each packet looks like the following in the XML:
<packet>
<proto name="geninfo" pos="0" showname="General information" size="54">
<field name="num" pos="0" show="1" showname="Number" value="1" size="54"/>
<field name="len" pos="0" show="54" showname="Frame Length" value="36" size="54"/>
<field name="caplen" pos="0" show="54" showname="Captured Length" value="36" size="54"/>
<field name="timestamp" pos="0" show="Aug 4, 2014 14:18:24.053628000 GMT Daylight Time" showname="Captured Time" value="1407158304.053628000" size="54"/>
</proto>
<proto name="frame" showname="Frame 1: 54 bytes on wire (432 bits), 54 bytes captured (432 bits) on interface 0" size="54" pos="0">
<field name="frame.interface_id" showname="Interface id: 0 (\Device\NPF_{F1D229D2-3ADA-4820-85D2-FCE7FB5D24E5})" size="0" pos="0" show="0"/>
<field name="frame.encap_type" showname="Encapsulation type: Ethernet (1)" size="0" pos="0" show="1"/>
<field name="frame.time" showname="Arrival Time: Aug 4, 2014 14:18:24.053628000 GMT Daylight Time" size="0" pos="0" show=""Aug 4, 2014 14:18:24.053628000 GMT Daylight Time""/>
<field name="frame.offset_shift" showname="Time shift for this packet: 0.000000000 seconds" size="0" pos="0" show="0.000000000"/>
<field name="frame.time_epoch" showname="Epoch Time: 1407158304.053628000 seconds" size="0" pos="0" show="1407158304.053628000"/>
<field name="frame.time_delta" showname="Time delta from previous captured frame: 0.000000000 seconds" size="0" pos="0" show="0.000000000"/>
<field name="frame.time_delta_displayed" showname="Time delta from previous displayed frame: 0.000000000 seconds" size="0" pos="0" show="0.000000000"/>
<field name="frame.time_relative" showname="Time since reference or first frame: 0.000000000 seconds" size="0" pos="0" show="0.000000000"/>
<field name="frame.number" showname="Frame Number: 1" size="0" pos="0" show="1"/>
<field name="frame.len" showname="Frame Length: 54 bytes (432 bits)" size="0" pos="0" show="54"/>
<field name="frame.cap_len" showname="Capture Length: 54 bytes (432 bits)" size="0" pos="0" show="54"/>
<field name="frame.marked" showname="Frame is marked: False" size="0" pos="0" show="0"/>
<field name="frame.ignored" showname="Frame is ignored: False" size="0" pos="0" show="0"/>
<field name="frame.protocols" showname="Protocols in frame: eth:ethertype:ip:tcp" size="0" pos="0" show="eth:ethertype:ip:tcp"/>
</proto>
<proto name="eth" showname="Ethernet II, Src: 78:e4:00:f9:ea:83 (78:e4:00:f9:ea:83), Dst: 98:8b:5d:b9:50:70 (98:8b:5d:b9:50:70)" size="14" pos="0">
<field name="eth.dst" showname="Destination: 98:8b:5d:b9:50:70 (98:8b:5d:b9:50:70)" size="6" pos="0" show="98:8b:5d:b9:50:70" value="988b5db95070">
<field name="eth.dst_resolved" showname="Destination (resolved): 98:8b:5d:b9:50:70" hide="yes" size="6" pos="0" show="98:8b:5d:b9:50:70" value="988b5db95070"/>
<field name="eth.addr" showname="Address: 98:8b:5d:b9:50:70 (98:8b:5d:b9:50:70)" size="6" pos="0" show="98:8b:5d:b9:50:70" value="988b5db95070"/>
<field name="eth.addr_resolved" showname="Address (resolved): 98:8b:5d:b9:50:70" hide="yes" size="6" pos="0" show="98:8b:5d:b9:50:70" value="988b5db95070"/>
<field name="eth.lg" showname=".... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)" size="3" pos="0" show="0" value="0" unmaskedvalue="988b5d"/>
<field name="eth.ig" showname=".... ...0 .... .... .... .... = IG bit: Individual address (unicast)" size="3" pos="0" show="0" value="0" unmaskedvalue="988b5d"/>
</field>
<field name="eth.src" showname="Source: 78:e4:00:f9:ea:83 (78:e4:00:f9:ea:83)" size="6" pos="6" show="78:e4:00:f9:ea:83" value="78e400f9ea83">
<field name="eth.src_resolved" showname="Source (resolved): 78:e4:00:f9:ea:83" hide="yes" size="6" pos="6" show="78:e4:00:f9:ea:83" value="78e400f9ea83"/>
<field name="eth.addr" showname="Address: 78:e4:00:f9:ea:83 (78:e4:00:f9:ea:83)" size="6" pos="6" show="78:e4:00:f9:ea:83" value="78e400f9ea83"/>
<field name="eth.addr_resolved" showname="Address (resolved): 78:e4:00:f9:ea:83" hide="yes" size="6" pos="6" show="78:e4:00:f9:ea:83" value="78e400f9ea83"/>
<field name="eth.lg" showname=".... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)" size="3" pos="6" show="0" value="0" unmaskedvalue="78e400"/>
<field name="eth.ig" showname=".... ...0 .... .... .... .... = IG bit: Individual address (unicast)" size="3" pos="6" show="0" value="0" unmaskedvalue="78e400"/>
</field>
<field name="eth.type" showname="Type: IP (0x0800)" size="2" pos="12" show="2048" value="0800"/>
</proto>
<proto name="ip" showname="Internet Protocol Version 4, Src: 192.168.1.204 (192.168.1.204), Dst: 162.159.242.165 (162.159.242.165)" size="20" pos="14">
<field name="ip.version" showname="Version: 4" size="1" pos="14" show="4" value="45"/>
<field name="ip.hdr_len" showname="Header Length: 20 bytes" size="1" pos="14" show="20" value="45"/>
<field name="ip.dsfield" showname="Differentiated Services Field: 0x00 (DSCP 0x00: Default; ECN: 0x00: Not-ECT (Not ECN-Capable Transport))" size="1" pos="15" show="0" value="00">
<field name="ip.dsfield.dscp" showname="0000 00.. = Differentiated Services Codepoint: Default (0x00)" size="1" pos="15" show="0" value="0" unmaskedvalue="00"/>
<field name="ip.dsfield.ecn" showname=".... ..00 = Explicit Congestion Notification: Not-ECT (Not ECN-Capable Transport) (0x00)" size="1" pos="15" show="0" value="0" unmaskedvalue="00"/>
</field>
<field name="ip.len" showname="Total Length: 40" size="2" pos="16" show="40" value="0028"/>
<field name="ip.id" showname="Identification: 0x1cf1 (7409)" size="2" pos="18" show="7409" value="1cf1"/>
<field name="ip.flags" showname="Flags: 0x02 (Don&apos;t Fragment)" size="1" pos="20" show="2" value="40">
<field name="ip.flags.rb" showname="0... .... = Reserved bit: Not set" size="1" pos="20" show="0" value="40"/>
<field name="ip.flags.df" showname=".1.. .... = Don&apos;t fragment: Set" size="1" pos="20" show="1" value="40"/>
<field name="ip.flags.mf" showname="..0. .... = More fragments: Not set" size="1" pos="20" show="0" value="40"/>
</field>
<field name="ip.frag_offset" showname="Fragment offset: 0" size="2" pos="20" show="0" value="4000"/>
<field name="ip.ttl" showname="Time to live: 128" size="1" pos="22" show="128" value="80"/>
<field name="ip.proto" showname="Protocol: TCP (6)" size="1" pos="23" show="6" value="06"/>
<field name="ip.checksum" showname="Header checksum: 0x8625 [validation disabled]" size="2" pos="24" show="34341" value="8625">
<field name="ip.checksum_good" showname="Good: False" size="2" pos="24" show="0" value="8625"/>
<field name="ip.checksum_bad" showname="Bad: False" size="2" pos="24" show="0" value="8625"/>
</field>
<field name="ip.src" showname="Source: 192.168.1.204 (192.168.1.204)" size="4" pos="26" show="192.168.1.204" value="c0a801cc"/>
<field name="ip.addr" showname="Source or Destination Address: 192.168.1.204 (192.168.1.204)" hide="yes" size="4" pos="26" show="192.168.1.204" value="c0a801cc"/>
<field name="ip.src_host" showname="Source Host: 192.168.1.204" hide="yes" size="4" pos="26" show="192.168.1.204" value="c0a801cc"/>
<field name="ip.host" showname="Source or Destination Host: 192.168.1.204" hide="yes" size="4" pos="26" show="192.168.1.204" value="c0a801cc"/>
<field name="ip.dst" showname="Destination: 162.159.242.165 (162.159.242.165)" size="4" pos="30" show="162.159.242.165" value="a29ff2a5"/>
<field name="ip.addr" showname="Source or Destination Address: 162.159.242.165 (162.159.242.165)" hide="yes" size="4" pos="30" show="162.159.242.165" value="a29ff2a5"/>
<field name="ip.dst_host" showname="Destination Host: 162.159.242.165" hide="yes" size="4" pos="30" show="162.159.242.165" value="a29ff2a5"/>
<field name="ip.host" showname="Source or Destination Host: 162.159.242.165" hide="yes" size="4" pos="30" show="162.159.242.165" value="a29ff2a5"/>
<field name="" show="Source GeoIP: Unknown" size="4" pos="26" value="c0a801cc"/>
<field name="" show="Destination GeoIP: Unknown" size="4" pos="30" value="a29ff2a5"/>
</proto>
<proto name="tcp" showname="Transmission Control Protocol, Src Port: 6287 (6287), Dst Port: 443 (443), Seq: 1, Ack: 1, Len: 0" size="20" pos="34">
<field name="tcp.srcport" showname="Source Port: 6287 (6287)" size="2" pos="34" show="6287" value="188f"/>
<field name="tcp.dstport" showname="Destination Port: 443 (443)" size="2" pos="36" show="443" value="01bb"/>
<field name="tcp.port" showname="Source or Destination Port: 6287" hide="yes" size="2" pos="34" show="6287" value="188f"/>
<field name="tcp.port" showname="Source or Destination Port: 443" hide="yes" size="2" pos="36" show="443" value="01bb"/>
<field name="tcp.stream" showname="Stream index: 0" size="0" pos="34" show="0"/>
<field name="tcp.len" showname="TCP Segment Len: 0" size="1" pos="46" show="0" value="50"/>
<field name="tcp.seq" showname="Sequence number: 1 (relative sequence number)" size="4" pos="38" show="1" value="b99b3a34"/>
<field name="tcp.ack" showname="Acknowledgment number: 1 (relative ack number)" size="4" pos="42" show="1" value="bd9a09d0"/>
<field name="tcp.hdr_len" showname="Header Length: 20 bytes" size="1" pos="46" show="20" value="50"/>
<field name="tcp.flags" showname=".... 0000 0001 0000 = Flags: 0x010 (ACK)" size="2" pos="46" show="16" value="10" unmaskedvalue="5010">
<field name="tcp.flags.res" showname="000. .... .... = Reserved: Not set" size="1" pos="46" show="0" value="0" unmaskedvalue="50"/>
<field name="tcp.flags.ns" showname="...0 .... .... = Nonce: Not set" size="1" pos="46" show="0" value="0" unmaskedvalue="50"/>
<field name="tcp.flags.cwr" showname=".... 0... .... = Congestion Window Reduced (CWR): Not set" size="1" pos="47" show="0" value="0" unmaskedvalue="10"/>
<field name="tcp.flags.ecn" showname=".... .0.. .... = ECN-Echo: Not set" size="1" pos="47" show="0" value="0" unmaskedvalue="10"/>
<field name="tcp.flags.urg" showname=".... ..0. .... = Urgent: Not set" size="1" pos="47" show="0" value="0" unmaskedvalue="10"/>
<field name="tcp.flags.ack" showname=".... ...1 .... = Acknowledgment: Set" size="1" pos="47" show="1" value="1" unmaskedvalue="10"/>
<field name="tcp.flags.push" showname=".... .... 0... = Push: Not set" size="1" pos="47" show="0" value="0" unmaskedvalue="10"/>
<field name="tcp.flags.reset" showname=".... .... .0.. = Reset: Not set" size="1" pos="47" show="0" value="0" unmaskedvalue="10"/>
<field name="tcp.flags.syn" showname=".... .... ..0. = Syn: Not set" size="1" pos="47" show="0" value="0" unmaskedvalue="10"/>
<field name="tcp.flags.fin" showname=".... .... ...0 = Fin: Not set" size="1" pos="47" show="0" value="0" unmaskedvalue="10"/>
</field>
<field name="tcp.window_size_value" showname="Window size value: 67" size="2" pos="48" show="67" value="0043"/>
<field name="tcp.window_size" showname="Calculated window size: 67" size="2" pos="48" show="67" value="0043"/>
<field name="tcp.window_size_scalefactor" showname="Window size scaling factor: -1 (unknown)" size="2" pos="48" show="-1" value="0043"/>
<field name="tcp.checksum" showname="Checksum: 0x8253 [validation disabled]" size="2" pos="50" show="33363" value="8253">
<field name="tcp.checksum_good" showname="Good Checksum: False" size="2" pos="50" show="0" value="8253"/>
<field name="tcp.checksum_bad" showname="Bad Checksum: False" size="2" pos="50" show="0" value="8253"/>
</field>
<field name="tcp.urgent_pointer" showname="Urgent pointer: 0" size="2" pos="52" show="0" value="0000"/>
</proto>
</packet>
I know it's very long but that is the format it comes in. What would be the best way to make the IP source a unique identifier, whilst adding the IP destinations to a list. It needs to be able to do this for every packet in the file.
Thanks, Tom.
i think #name of the <field> is unique across all the packets so that i apply following xpath
XmlNode node = xmlDoc2.DocumentElement;
var results = node.SelectNodes("//field[#name='ip.src']");
foreach (XmlNode result in results)
{
Console.WriteLine(result.Attributes["show"].Value);
}
--SJ

XML to DataSet conversion is giving me error

I am converting XML data to dataset with following code:
Public Function ReadXML(ByVal xmlData As String) As DataSet
Dim stream As StringReader = Nothing
Dim reader As XmlTextReader = Nothing
Try
Dim xmlDS As New DataSet()
stream = New StringReader(xmlData)
' Load the XmlTextReader from the stream
reader = New XmlTextReader(stream)
xmlDS.ReadXml(reader)
Return xmlDS
Catch
Return Nothing
Finally
If reader IsNot Nothing Then
reader.Close()
End If
End Try
End Function
xmlData is parameter to function which gives path to xml file.
when the code is on line:
xmlDS.ReadXml(reader) it throws me error:
XMLException was caught: Data at the root level is invalid. Line 1, position 1.
I am not able to understand why is this happening.
Please help me, Answer in c# can also help me.
C# equivalent function for this:
public DataSet ConvertXMLToDataSet(string xmlData)
{
StringReader stream = null;
XmlTextReader reader = null;
try
{
DataSet xmlDS = new DataSet() ;
stream = new StringReader(xmlData);
// Load the XmlTextReader from the stream
reader = new XmlTextReader(stream);
xmlDS.ReadXml(reader);
return xmlDS;
}
catch
{
return null;
}
finally
{
if(reader != null) reader.Close();
}
}// Use this function to get XML string from a dataset
Please help me.
XML:
<?xml version="1.0" encoding="UTF-8"?>
-<movieinfo creationdate="8/30/2013 11:32:21 AM"> -<localizedtemplatetexts> <field label="Movie Details" id="ttMovieDetails"/> <field label="Cast" id="ttCast"/> <field label="Crew" id="ttCrew"/> <field label="Disc" id="ttDisc"/> <field label="Edition Details" id="ttProductDetails"/> <field label="Personal Details" id="ttPersonalDetails"/> <field label="Episodes" id="ttEpisodeDetails"/> <field label="Images" id="ttImageLinkDetails"/> <field label="Images" id="ttMCEToggleImages"/> <field label="List" id="ttMCEToggleList"/> <field label="First" id="ttFirst"/> <field label="Previous" id="ttPrev"/> <field label="Up" id="ttUp"/> <field label="Next" id="ttNext"/> <field label="Last" id="ttLast"/> <field label="Buy this movie online" id="ttBuyOnline"/> </localizedtemplatetexts> -<moviemetadata> <field label="Index" id="dfIndex" name="Index"/> <field label="Loaned To" id="dfLoaner" name="Loaned To"/> <field label="Loan Date" id="dfLoanDate" name="Loan Date"/> <field label="Due Date" id="dfDueDate" name="Due Date"/> <field label="Overdue" id="dfIsOverdue" name="Overdue"/> <field label="Return Date" id="dfReturnDate" name="Return Date"/> <field label="Loan Notes" id="dfLoanNotes" name="Loan Notes"/> <field label="Loaner Email" id="dfLoanEmail" name="Loaner Email"/> <field label="Loaner Address" id="dfLoanAddress" name="Loaner Address"/> <field label="Title" id="dfLoanTitle" name="Title"/> <field label="Title" id="dfTitle" name="Title"/> <field label="Title Sort" id="dfTitleSort" name="Title Sort"/> <field label="Title Extension" id="dfTitleExtension" name="Title Extension"/> <field label="Collection Status" id="dfCollectionStatus" name="Collection Status"/> <field label="Plot" id="dfPlot" name="Plot"/> <field label="Running Time" id="dfRunTime" name="Running Time"/> <field label="No. of Disks/Tapes" id="dfNrItems" name="No. of Disks/Tapes"/> <field label="Barcode" id="dfUPC" name="Barcode"/> <field label="Movie Release Date" id="dfReleaseDate" name="Movie Release Date"/> <field label="Release Date" id="dfDVDReleaseDate" name="Release Date"/> <field label="IMDb Number" id="dfIMDBNumber" name="IMDb Number"/> <field label="IMDb Rating" id="dfIMDBRating" name="IMDb Rating"/> <field label="TMDb ID" id="dfMovieDbID" name="TMDb ID"/> <field label="Color" id="dfColor" name="Color"/> <field label="Layers" id="dfLayers" name="Layers"/> <field label="Front Cover" id="dfCoverFront" name="Front Cover"/> <field label="Back Cover" id="dfCoverBack" name="Back Cover"/> <field label="Movie Poster" id="dfMoviePoster" name="Movie Poster"/> <field label="Backdrop" id="dfBackDrop" name="Backdrop"/> <field label="My Rating" id="dfMyRating" name="My Rating"/> <field label="Seen It" id="dfSeenIt" name="Seen It"/> <field label="Viewing Date" id="dfSeenWhen" name="Viewing Date"/> <field label="Viewing Year" id="dfSeenYear" name="Viewing Year"/> <field label="Seen Where" id="dfSeenWhere" name="Seen Where"/> <field label="Purchase Date" id="dfPurchaseDate" name="Purchase Date"/> <field label="Purchase Year" id="dfPurchaseYear" name="Purchase Year"/> <field label="Purchase Price" id="dfPurchasePrice" name="Purchase Price"/> <field label="Location" id="dfLocation" name="Location"/> <field label="Starting Position" id="dfStartPos" name="Starting Position"/> <field label="Tape Speed" id="dfTapeSpeed" name="Tape Speed"/> <field label="Notes" id="dfNotes" name="Notes"/> <field label="Links" id="dfLinks" name="Links"/> <field label="Movie Files" id="dfMovieLinks" name="Movie Files"/> <field label="Image Files" id="dfImageLinks" name="Image Files"/> <field label="Other Files" id="dfOtherLinks" name="Other Files"/> <field label="Trailer URLs" id="dfLinkTrailers" name="Trailer URLs"/> <field label="Trailer Files" id="dfTrailerFiles" name="Trailer Files"/> <field label="Quantity" id="dfQuantity" name="Quantity"/> <field label="Current Value" id="dfCurrentValue" name="Current Value"/> <field label="Storage Device" id="dfStorageDevice" name="Storage Device"/> <field label="Slot" id="dfStorageSlot" name="Slot"/> <field label="Episodes" id="dfEpisodes" name="Episodes"/> <field label="Chapters" id="dfChapters" name="Chapters"/> <field label="Extra Features" id="dfExtraFeatures" name="Extra Features"/> <field label="Actor" id="dfActor" name="Actor"/> <field label="Genre" id="dfGenre" name="Genre"/> <field label="Director" id="dfDirector" name="Director"/> <field label="Edition" id="dfEdition" name="Edition"/> <field label="Movie Release Year" id="dfReleaseYear" name="Movie Release Year"/> <field label="Format" id="dfFormat" name="Format"/> <field label="Region" id="dfRegion" name="Region"/> <field label="Release Year" id="dfDVDReleaseYear" name="Release Year"/> <field label="Series" id="dfSeries" name="Series"/> <field label="Box set" id="dfBoxSet" name="Box set"/> <field label="Audience Rating" id="dfMPAARating" name="Audience Rating"/> <field label="Studio" id="dfStudio" name="Studio"/> <field label="Distributor" id="dfDistributor" name="Distributor"/> <field label="Extras" id="dfExtras" name="Extras"/> <field label="Country" id="dfCountry" name="Country"/> <field label="Language" id="dfLanguage" name="Language"/> <field label="Plot Language" id="dfPlotLanguage" name="Plot Language"/> <field label="Original Title" id="dfOriginalTitle" name="Original Title"/> <field label="Screen Ratio" id="dfRatio" name="Screen Ratio"/> <field label="Packaging" id="dfPackage" name="Packaging"/> <field label="Subtitles" id="dfSubtitles" name="Subtitles"/> <field label="Audio Tracks" id="dfAudio" name="Audio Tracks"/> <field label="Store" id="dfStore" name="Store"/> <field label="Owner" id="dfOwner" name="Owner"/> <field label="Tape Label" id="dfTapeLabel" name="Tape Label"/> <field label="Condition" id="dfCondition" name="Condition"/> <field label="Tags" id="dfTag" name="Tags"/> <field label="Producer" id="dfProducer" name="Producer"/> <field label="Writer" id="dfWriter" name="Writer"/> <field label="Cinematography" id="dfCamera" name="Cinematography"/> <field label="Musician" id="dfMusic" name="Musician"/> <field label="User Credit 1" id="dfUserCredit1" name="User Credit 1"/> <field label="User Credit 2" id="dfUserCredit2" name="User Credit 2"/> <field label="Features" id="dfFeatures" name="Features"/> <field label="Title" id="dfEpisodeTitle" name="Title"/> <field label="Disc No." id="dfEpisodeDiscNr" name="Disc No."/> <field label="Plot" id="dfEpisodePlot" name="Plot"/> <field label="Running Time" id="dfEpisodeRunTime" name="Running Time"/> <field label="First Air Date" id="dfEpisodeFirstAirDate" name="First Air Date"/> <field label="Sequence No" id="dfEpisodeSequenceNr" name="Sequence No"/> <field label="Movie Link" id="dfEpisodeMovieLink" name="Movie Link"/> <field label="Internet Link" id="dfEpisodeLink" name="Internet Link"/> <field label="Image Link" id="dfEpisodeImageLink" name="Image Link"/> <field label="IMDB Number" id="dfEpisodeIMDBNumber" name="IMDB Number"/> <field label="Seen It" id="dfEpisodeSeenIt" name="Seen It"/> <field label="Viewing Date" id="dfEpisodeSeenWhen" name="Viewing Date"/> <field label="Seen Where" id="dfEpisodeSeenWhere" name="Seen Where"/> <field label="Disc No." id="strDiscNr" name="Disc No."/> <field label="Number Of Episodes" id="strNrEpisodes" name="Number Of Episodes"/> <field label="User Lookup 1" id="dfUserLookup1" name="User Lookup 1"/> <field label="User Lookup 2" id="dfUserLookup2" name="User Lookup 2"/> <field label="User Text 1" id="dfUserText1" name="User Text 1"/> <field label="User Text 2" id="dfUserText2" name="User Text 2"/> <field label="In Collection (0/1)" id="dfInCollectionBit" name="In Collection (0/1)"/> <field label="ID" id="dfID" name="ID"/> <field label="Last Modified" id="dfLastModified" name="Last Modified"/> <field label="Thumbnail" id="dfThumbFilePath" name="Thumbnail"/> <field label="Last Submission Date" id="dfSubmissionDate" name="Last Submission Date"/> <field label="Clz Movie ID" id="dfBPMovieID" name="Clz Movie ID"/> <field label="Clz Media ID" id="dfBPMediaID" name="Clz Media ID"/> <field label="BPOnline Movie Last Received Revision" id="dfBPMovieLastReceivedRevision" name="BPOnline Movie Last Received Revision"/> <field label="BPOnline Media Last Received Revision" id="dfBPMediaLastReceivedRevision" name="BPOnline Media Last Received Revision"/> <field label="Title First Letter" id="dfDynTitleLetter" name="Title First Letter"/> <field label="My Rating" id="dfDynRating" name="My Rating"/> </moviemetadata> -<movielist> -<movie> <id>701</id> <index>11</index> <coverfront>C:\Users\Administrator\Documents\Movie Collector\Images\Brave2012701_f.jpg</coverfront> <poster>C:\Users\Administrator\Documents\Movie Collector\Images\Brave2012701_p.jpg</poster> <backdropurl>C:\Users\Administrator\Documents\Movie Collector\Images\Brave2012701_d.jpg</backdropurl> <backgroundbackdrop>CLZBACKDROP</backgroundbackdrop> <imdburl>http://www.imdb.com/title/tt1217209</imdburl> <imdbnum>1217209</imdbnum> <imdbrating>7.3</imdbrating> <imdbvotes>66509</imdbvotes> <tmdbid>62177</tmdbid> <tmdburl>http://themoviedb.org/movie/62177</tmdburl> -<format> <displayname>Blu-ray Disc</displayname> <templateimage>C:\Users\Administrator\Documents\Movie Collector\Images\Listitemimages\bluray.jpg</templateimage> <scaledimage>C:\Users\Administrator\Documents\Movie Collector\Images\Listitemimages\bluray16x16.bmp</scaledimage> <sortname>Blu-ray Disc</sortname> </format> -<country> <displayname>USA</displayname> <templateimage>C:\Users\Administrator\Documents\Movie Collector\Images\Listitemimages\usa.jpg</templateimage> <scaledimage>C:\Users\Administrator\Documents\Movie Collector\Images\Listitemimages\usa16.jpg</scaledimage> <sortname>USA</sortname> </country> <collectionstatus listid="3">In Collection</collectionstatus> -<language> <displayname>English</displayname> <templateimage>C:\Users\Administrator\Documents\Movie Collector\Images\Listitemimages\uk.jpg</templateimage> <scaledimage>C:\Users\Administrator\Documents\Movie Collector\Images\Listitemimages\uk16.jpg</scaledimage> <sortname>English</sortname> </language> -<store> <displayname>Amazon</displayname> <sortname>Amazon</sortname> </store> <purchaseprice>$20.00</purchaseprice> <series/> <boxset/> -<purchasedate> -<year> <displayname>2012</displayname> </year> <month>12</month> <day>10</day> <date>12/10/2012</date> </purchasedate> -<owner> <displayname>John Doe</displayname> <sortname>John Doe</sortname> </owner> <title>Brave</title> <plot>Brave is set in the mystical Scottish Highlands, where Mérida is the princess of a kingdom ruled by King Fergus and Queen Elinor. An unruly daughter and an accomplished archer, Mérida one day defies a sacred custom of the land and inadvertently brings turmoil to the kingdom. In an attempt to set things right, Mérida seeks out an eccentric old Wise Woman and is granted an ill-fated wish. Also figuring into Mérida’s quest — and serving as comic relief — are the kingdom’s three lords: the enormous Lord MacGuffin, the surly Lord Macintosh, and the disagreeable Lord Dingwall.</plot> <myrating>9</myrating> -<myrating> <displayname>9</displayname> <sortname>9</sortname> </myrating> <seenit boolvalue="1">Yes</seenit> -<viewingdate> -<year> <displayname>2012</displayname> </year> <month>12</month> <day>10</day> <date>12/10/2012</date> </viewingdate> -<edition> <displayname>Collector's Edition</displayname> <sortname>Collector's Edition</sortname> </edition> -<condition> <displayname>Excellent</displayname> <sortname>090 Excellent</sortname> <lastname>090 Excellent</lastname> </condition> -<releasedate> -<year> <displayname>2012</displayname> </year> <date>2012</date> </releasedate> -<dvdreleasedate> -<year> <displayname>2012</displayname> </year> <month>11</month> <day>13</day> <date>11/13/2012</date> </dvdreleasedate> -<mpaarating> <displayname>PG (Parental Guidance)</displayname> <templateimage>C:\Users\Administrator\Documents\Movie Collector\Images\Listitemimages\pg.jpg</templateimage> <scaledimage>C:\Users\Administrator\Documents\Movie Collector\Images\Listitemimages\pg-16x16.jpg</scaledimage> <sortname>PG (Parental Guidance)</sortname> </mpaarating> <seenwhere>Home</seenwhere> <upc>786936828344</upc> <package/> -<location> <displayname>Moviebox 34</displayname> <sortname>Moviebox 34</sortname> </location> <tapelabel/> <runtime>93</runtime> <runtimeminutes>93 mins</runtimeminutes> <layersnum>1</layersnum> <layers listid="1">Single Side, Dual Layer</layers> <chapters>0</chapters> <nritems>5</nritems> <quantity>1</quantity> <color listid="0">Color</color> <tapespeed listid="0">N/A</tapespeed> -<genres> -<genre> <displayname>Action</displayname> <sortname>Action</sortname> </genre> -<genre> <displayname>Adventure</displayname> <sortname>Adventure</sortname> </genre> -<genre> <displayname>Animation</displayname> <sortname>Animation</sortname> </genre> -<genre> <displayname>Comedy</displayname> <sortname>Comedy</sortname> </genre> -<genre> <displayname>Family</displayname> <sortname>Family</sortname> </genre> </genres> -<cast> -<star> <role id="dfActor">Actor</role> <roleid>dfActor</roleid> -<person> <displayname>Kelly MacDonald</displayname> <sortname>MacDonald, Kelly</sortname> <lastname>MacDonald</lastname> <url>http://www.imdb.com/name/nm0531808/</url> <firstname>Kelly</firstname> <imageurl>http://clzimages.com/movie/banners/actors/small/09/09_24708_4_KellyMacDonald.jpg</imageurl> </person> <character>Merida</character> </star> -<star> <role id="dfActor">Actor</role> <roleid>dfActor</roleid> -<person> <displayname>Billy Connolly</displayname> <sortname>Connolly, Billy</sortname> <lastname>Connolly</lastname> <url>http://www.imdb.com/name/nm0175262/</url> <firstname>Billy</firstname> <imageurl>http://clzimages.com/movie/banners/actors/small/b4/b4_3429_4_BillyConnolly.jpg</imageurl> </person> <character>Fergus</character> </star> -<star> <role id="dfActor">Actor</role> <roleid>dfActor</roleid> -<person> <displayname>Emma Thompson</displayname> <sortname>Thompson, Emma</sortname> <lastname>Thompson</lastname> <url>http://www.imdb.com/name/nm0000668/</url> <firstname>Emma</firstname> <imageurl>http://clzimages.com/movie/banners/actors/small/13/13_8549_4_EmmaThompson.jpg</imageurl> </person> <character>Elinor</character> </star> -<star> <role id="dfActor">Actor</role> <roleid>dfActor</roleid> -<person> <displayname>Julie Walters</displayname> <sortname>Walters, Julie</sortname> <lastname>Walters</lastname> <url>http://www.imdb.com/name/nm0910278/</url> <firstname>Julie</firstname> <imageurl>http://clzimages.com/movie/banners/actors/small/20/20_14643_4_JulieWalters.jpg</imageurl> </person> <character>The Witch</character> </star> -<star> <role id="dfActor">Actor</role> <roleid>dfActor</roleid> -<person> <displayname>Robbie Coltrane</displayname> <sortname>Coltrane, Robbie</sortname> <lastname>Coltrane</lastname> <url>http://www.imdb.com/name/nm0001059/</url> <firstname>Robbie</firstname> <imageurl>http://clzimages.com/movie/banners/actors/small/d0/d0_92_4_RobbieColtrane.jpg</imageurl> </person> <character>Lord Dingwall</character> </star> -<star> <role id="dfActor">Actor</role> <roleid>dfActor</roleid> -<person> <displayname>Kevin McKidd</displayname> <sortname>McKidd, Kevin</sortname> <lastname>McKidd</lastname> <url>http://www.imdb.com/name/nm0571727/</url> <firstname>Kevin</firstname> <imageurl>http://clzimages.com/movie/banners/actors/small/b8/b8_3557_4_KevinMcKidd.jpg</imageurl> </person> <character>Lord MacGuffin/Young MacGuffin</character> </star> -<star> <role id="dfActor">Actor</role> <roleid>dfActor</roleid> -<person> <displayname>Craig Ferguson</displayname> <sortname>Ferguson, Craig</sortname> <lastname>Ferguson</lastname> <url>http://www.imdb.com/name/nm0272401/</url> <firstname>Craig</firstname> <imageurl>http://clzimages.com/movie/banners/actors/small/17/17_17423_4_CraigFerguson.jpg</imageurl> </person> <character>Lord Macintosh</character> </star> -<star> <role id="dfActor">Actor</role> <roleid>dfActor</roleid> -<person> <displayname>Sally Kinghorn</displayname> <sortname>Kinghorn, Sally</sortname> <lastname>Kinghorn</lastname> <firstname>Sally</firstname> </person> <character>Maudie</character> </star> -<star> <role id="dfActor">Actor</role> <roleid>dfActor</roleid> -<person> <displayname>Eilidh Fraser</displayname> <sortname>Fraser, Eilidh</sortname> <lastname>Fraser</lastname> <firstname>Eilidh</firstname> </person> <character>Maudie</character> </star> -<star> <role id="dfActor">Actor</role> <roleid>dfActor</roleid> -<person> <displayname>Peigi Barker</displayname> <sortname>Barker, Peigi</sortname> <lastname>Barker</lastname> <firstname>Peigi</firstname> </person> <character>Young Merida</character> </star> -<star> <role id="dfActor">Actor</role> <roleid>dfActor</roleid> -<person> <displayname>Steven Cree</displayname> <sortname>Cree, Steven</sortname> <lastname>Cree</lastname> <firstname>Steven</firstname> </person> <character>Young Macintosh</character> </star> -<star> <role id="dfActor">Actor</role> <roleid>dfActor</roleid> -<person> <displayname>Steve Purcell</displayname> <sortname>Purcell, Steve</sortname> <lastname>Purcell</lastname> <firstname>Steve</firstname> </person> <character>The Crow</character> </star> -<star> <role id="dfActor">Actor</role> <roleid>dfActor</roleid> -<person> <displayname>Callum O'Neill</displayname> <sortname>O'Neill, Callum</sortname> <lastname>O'Neill</lastname> <firstname>Callum</firstname> </person> <character>Wee Dingwall</character> </star> -<star> <role id="dfActor">Actor</role> <roleid>dfActor</roleid> -<person> <displayname>Patrick Doyle</displayname> <sortname>Doyle, Patrick</sortname> <lastname>Doyle</lastname> <firstname>Patrick</firstname> </person> <character>Martin</character> </star> -<star> <role id="dfActor">Actor</role> <roleid>dfActor</roleid> -<person> <displayname>John Ratzenberger</displayname> <sortname>Ratzenberger, John</sortname> <lastname>Ratzenberger</lastname> <url>http://www.imdb.com/name/nm0001652/</url> <firstname>John</firstname> <imageurl>http://clzimages.com/movie/banners/actors/small/d2/d2_14840_4_JohnRatzenberger.jpg</imageurl> </person> <character>Gordon</character> </star> </cast> -<crew> -<crewmember> <role id="dfDirector">Director</role> <roleid>dfDirector</roleid> -<person> <displayname>Steve Purcell</displayname> <sortname>Purcell, Steve</sortname> <lastname>Purcell</lastname> <url>http://www.imdb.com/name/nm0700760/</url> <firstname>Steve</firstname> <imageurl>http://clzimages.com/movie/banners/employees/small/0e/0e_3199_4_StevePurcell.jpg</imageurl> </person> </crewmember> -<crewmember> <role id="dfDirector">Director</role> <roleid>dfDirector</roleid> -<person> <displayname>Brenda Chapman</displayname> <sortname>Chapman, Brenda</sortname> <lastname>Chapman</lastname> <url>http://www.imdb.com/name/nm0152312/</url> <firstname>Brenda</firstname> <imageurl>http://clzimages.com/movie/banners/employees/small/32/32_6810_4_BrendaChapman.jpg</imageurl> </person> </crewmember> -<crewmember> <role id="dfWriter">Writer</role> <roleid>dfWriter</roleid> -<person> <displayname>Steve Purcell</displayname> <sortname>Purcell, Steve</sortname> <lastname>Purcell</lastname> <firstname>Steve</firstname> </person> </crewmember> -<crewmember> <role id="dfWriter">Writer</role> <roleid>dfWriter</roleid> -<person> <displayname>Brenda Chapman</displayname> <sortname>Chapman, Brenda</sortname> <lastname>Chapman</lastname> <firstname>Brenda</firstname> </person> </crewmember> -<crewmember> <role id="dfProducer">Producer</role> <roleid>dfProducer</roleid> -<person> <displayname>Andrew Stanton</displayname> <sortname>Stanton, Andrew</sortname> <lastname>Stanton</lastname> <firstname>Andrew</firstname> </person> </crewmember> -<crewmember> <role id="dfProducer">Producer</role> <roleid>dfProducer</roleid> -<person> <displayname>John Lasseter</displayname> <sortname>Lasseter, John</sortname> <lastname>Lasseter</lastname> <firstname>John</firstname> </person> </crewmember> -<crewmember> <role id="dfMusic">Musician</role> <roleid>dfMusic</roleid> -<person> <displayname>Patrick Doyle</displayname> <sortname>Doyle, Patrick</sortname> <lastname>Doyle</lastname> <firstname>Patrick</firstname> </person> </crewmember> </crew> -<regions> -<region> <displayname>Region 1</displayname> <templateimage>C:\Users\Administrator\Documents\Movie Collector\Images\Listitemimages\r-1.jpg</templateimage> <scaledimage>C:\Users\Administrator\Documents\Movie Collector\Images\Listitemimages\r-1-16x16.jpg</scaledimage> <sortname>Region 1</sortname> </region> -<region> <displayname>Region A</displayname> <templateimage>C:\Users\Administrator\Documents\Movie Collector\Images\Listitemimages\r-A.jpg</templateimage> <scaledimage>C:\Users\Administrator\Documents\Movie Collector\Images\Listitemimages\r-A-16x16.jpg</scaledimage> <sortname>Region A</sortname> </region> </regions> -<ratios> -<ratio> <displayname>Theatrical Widescreen (2.35:1)</displayname> <sortname>Theatrical Widescreen (2.35:1)</sortname> </ratio> </ratios> -<subtitles> -<subtitle> <displayname>English (Closed Captioned)</displayname> <sortname>English (Closed Captioned)</sortname> </subtitle> -<subtitle> <displayname>French</displayname> <sortname>French</sortname> </subtitle> -<subtitle> <displayname>Spanish</displayname> <sortname>Spanish</sortname> </subtitle> </subtitles> <features/> -<audios> -<audio> <displayname>Dolby Digital 5.1 [Spanish]</displayname> <templateimage>C:\Users\Administrator\Documents\Movie Collector\Images\Listitemimages\dolbydigital-51.png</templateimage> <sortname>Dolby Digital 5.1 [Spanish]</sortname> </audio> -<audio> <displayname>DTS [English]</displayname> <templateimage>C:\Users\Administrator\Documents\Movie Collector\Images\Listitemimages\dts.png</templateimage> <sortname>DTS [English]</sortname> </audio> -<audio> <displayname>DTS [French]</displayname> <templateimage>C:\Users\Administrator\Documents\Movie Collector\Images\Listitemimages\dts.png</templateimage> <sortname>DTS [French]</sortname> </audio> </audios> -<studios> -<studio> <displayname>Pixar</displayname> <sortname>Pixar</sortname> </studio> </studios> -<distributor> <displayname>Buena Vista</displayname> <sortname>Buena Vista</sortname> </distributor> <extras/> <tags/> <userlookup1/> <userlookup2/> -<links> -<link> <description>Amazon.com</description> <url>http://www.amazon.com/gp/search?keywords=786936828344+Brave&tag=collectorzapp-20&index=dvd</url> <urltype>URL</urltype> </link> -<link> <description>Movie Collector Connect</description> <url>http://connect.collectorz.com/movies/database/brave-2012</url> <urltype>URL</urltype> </link> -<link> <description>IMDB</description> <url>http://www.imdb.com/title/tt1217209</url> <urltype>URL</urltype> </link> -<link> <description>TheMovieDb.org</description> <url>http://www.themoviedb.org/movie/62177</url> <urltype>URL</urltype> </link> -<link> <description>Trailer</description> <url>http://www.youtube.com/watch?v=tYg0VgPy6Uk</url> <urltype>Trailer URL</urltype> </link> </links> <episodecount>0</episodecount> -<lastmodified> <date>12/10/2012 4:37:03 PM</date> </lastmodified> <thumbfilepath>C:\Users\Administrator\Documents\Movie Collector\Thumbnails\CBF03186E647BB05BC635F286DC84E34.jpg</thumbfilepath> <bpmovieid>140538</bpmovieid> <bpmediaid>496821</bpmediaid> <bpmovielastreceivedrevision>58</bpmovielastreceivedrevision> <bpmedialastreceivedrevision>0</bpmedialastreceivedrevision> <plotlanguage/> <storagedevice/> -<titlefirstletter> <displayname>B</displayname> <sortname>B</sortname> </titlefirstletter> -<discs> -<disc> <title>Disc 01</title> <features/> <storagedevice/> <episodes/> </disc> -<disc> <title>Disc 02</title> <features/> <storagedevice/> <episodes/> </disc> -<disc> <title>Disc 03</title> <features/> <storagedevice/> <episodes/> </disc> -<disc> <title>Disc 04</title> <features/> <storagedevice/> <episodes/> </disc> -<disc> <title>Disc 05</title> <features/> <storagedevice/> <episodes/> </disc> </discs> <submissiondate/> </movie> </movielist> </movieinfo>
http://www.amazon.com/gp/search?keywords=786936828344+Bravetag=collectorzapp-20&index=dvd
This URL Form xml file giving error.
Remember one thing XML not Accept "&"
Two things:
First, your XML contains a lot of - characters (maybe you copied these from a Xml-editor or viewer unintentional).
Second, your XML contains a some unescaped &s in URLs; these have to be escaped (use & instead of &). Take a look at the XML specification:
The ampersand character (&) and the left angle bracket (<) may appear in their literal form only when used as markup delimiters, or within a comment, a processing instruction, or a CDATA section. If they are needed elsewhere, they must be escaped using either numeric character references or the strings "&" and "<" respectively.
StringReader reads a literal string.
Use StreamReader instead.
Or use it like :
http://forums.asp.net/t/1247855.aspx/1 giving path

Hide ComboBox and/or DateField based on Radio Button selection in Ext.net codebehind

I am trying to hide a ComboBox and/or DateFields based on my selected radio button in the codebehind in Ext.net
<Items>
<ext:Container ID="Container1" runat="server" Layout="ColumnLayout" Height="175" Width="418" >
<Items>
<ext:RadioGroup runat="server" ID="ChooseSpan" Selectable="true" ColumnsNumber="1" ColumnWidth="0.50" >
<Items>
<ext:Radio ID="RadioAll" runat="server" BoxLabel="Show All" InputValue="0" />
<ext:Radio ID="RadioMonth" runat="server" BoxLabel="Choose Date Range(By Month)" InputValue="1" />
<ext:Radio ID="RadioDate" runat="server" BoxLabel="Choose Date Range(By Dates)" InputValue="2" />
</Items>
</ext:RadioGroup>
<ext:Container ID="Container2" runat="server" Layout="RowLayout" Height="175" ColumnWidth="0.50" StyleSpec="margin-top:25px;">
<Items>
<ext:ComboBox runat="server" ID="MonthComboBox" Selectable="true" SelectedIndex="0" >
<Items>
<ext:ListItem Text="Any Month" Value="0" />
<ext:ListItem Text="January" Value="1" />
<ext:ListItem Text="February" Value="2" />
<ext:ListItem Text="March" Value="3" />
<ext:ListItem Text="April" Value="4" />
<ext:ListItem Text="May" Value="5" />
<ext:ListItem Text="June" Value="6" />
<ext:ListItem Text="July" Value="7" />
<ext:ListItem Text="August" Value="8" />
<ext:ListItem Text="September" Value="9" />
<ext:ListItem Text="October" Value="10" />
<ext:ListItem Text="November" Value="11" />
<ext:ListItem Text="December" Value="12" />
</Items>
</ext:ComboBox>
<ext:DateField
ID="StartDateField"
runat="server"
FieldLabel="Start"
Vtype="daterange"
AnchorHorizontal="100%"
EnableKeyEvents="true">
<CustomConfig>
<ext:ConfigItem Name="endDateField" Value="#{EndDateField}" Mode="Value" />
</CustomConfig>
<Listeners>
<%--<Select Handler="#{DirectMethods}.SubmitDate();" />--%>
</Listeners>
</ext:DateField>
<ext:DateField
ID="EndDateField"
runat="server"
Vtype="daterange"
FieldLabel="End"
AnchorHorizontal="100%"
EnableKeyEvents="true">
<CustomConfig>
<ext:ConfigItem Name="startDateField" Value="#{StartDateField}" Mode="Value" />
</CustomConfig>
<Listeners>
<%-- <Select Handler="#{DirectMethods}.SubmitDate();" />--%>
</Listeners>
</ext:DateField>
<ext:Button ID="Next" runat="server" Text="Next" MaxWidth="50" StyleSpec="margin-left:159px; margin-top:150;" >
</ext:Button>
</Items>
</ext:Container>
</Items>
</ext:Container>
</Items>
</ext:Panel>
</Items>
here is the code behind using C#:
[DirectMethod]
public void DateSelection()
{
if (ChooseSpan.CheckedItems[0].ID == "RadioAll")
{
MonthComboBox.Visible = false;
StartDateField.Visible = false;
EndDateField.Visible = false;
}
if (ChooseSpan.CheckedItems[0].ID == "RadioMonth")
{
MonthComboBox.Visible = true;
MonthComboBox.Show();
StartDateField.Visible = false;
EndDateField.Visible = false;
}
if (ChooseSpan.CheckedItems[0].ID == "RadioDate")
{
MonthComboBox.Visible = false;
StartDateField.Visible = true;
StartDateField.Show();
EndDateField.Visible = true;
EndDateField.Show();
}
}
Do i need a listener in the RadioGroup to accept these selections? how do i get the codebehind to respond to my selection, and tell it to hide or not?
Please listen the RadioGroup's Change event to call a server method.
To hide/show the components please use the Hidden property instead of the Visible one. Here is a bit of details about the difference.
As well you can use the Show and Hide methods.

Categories