.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Post New Web Links

only outputs first child node

Posted By:      Posted Date: April 10, 2011    Points: 0   Category :ASP.Net
<?xml version="1.0" encoding="utf-8"?>
     <category id="10" name="Amet"/>
     <category id="20" name="Dolor"/>
     <category id="30" name="conse"/>
     <category id="40" name="Lorem"/>
	<product id="1905" title="KKLorem ipsum dolor sit amet, consectetur a" description="bbloren ipsum dipsum" >
	  <category id="10"/>
	  <category id="20"/>
	  <category id="30"/>
	  <category id="40"/>
	<product id="2100" title="JJLorem ipsum dolor sit amet, consectetur a" description="aaloren ipsum dipsum" >
	  <category id="20"/>


Code used to read the above file


string pathToXml = Server.MapPath("/App_Data/DataFile.xml");
XDocument order = XDocument.Load(pathToXml);

var products = from c in order.Element("catalog").Elements("categories")
 select new {   po = c.Element("category").Attribute("id").Value   };

foreach (var item in products)
  { Response.Write(item.po); }

The above code only outputs the first line

?????????<category id="10"  name="Amet" />

 I thought the

View Complete Post

More Related Resource Links

Display homepage node along with child nodes


If the first Sitemap node is your homepage/default and all other nodes are supposed to be children / grandchildren of the first sitemap node in a web.sitemap, how do I set up my web.sitemap to enable me to display my cssFriendlyMenu with the homepage node along with the nodes that are 1 level down from it at the same time as in :

Home   Products   Services   About us


...or is it not possible to have the first sitemap node displayed along with the nodes that are 1 level down from it?  Do I need to have a different starting node rather than my homepage node?

Display error if a treeview root node contains a child node

I am having a treeview initially with a root node when form is loaded. I will add child node as some.txt file at the runtime by selecting an option as Addnew from contextmenu which was displayed when the user right clicks on the root node. Now what i need is if the tree has child node appended to the Root and if user tries to create a new node by clicking the option addnew from context menu i would like to display an error as only one child allowed.   Can any one help

delete node based on child value

Trying to delete a node via linq to xml but don't seem to be creating my query just right. My xml looks like this: <Index><Document>    <FriendlyName>test</FriendlyName>    <ID>f1eb6439-56dc-4f8a-a02a-c97706646643</ID>    <Post>True</Post>    <Department>Clearance</Department>    <Category>Information</Category>    <Audience></Audience>    <Link Type="Page" Target=""><![CDATA[]]></Link>    <Keywords></Keywords>  </Document></Index>   I know the ID that i want and is stored in variable myID Now I need to search my xml & find the entry that matches myID Then delete the entire Document element & all child nodes.   Here's what I've been playing with but it's just not quite there. myxmldoc.Elements("Document").Where(s => s.Element("ID").Value == myID).Remove();    Thanks ahead for the help!

Add to xml node as a first child


Hi Folks,

I am new with ASP.NET, trying to build an application with the help of googling, now in XML section when I am updating my XML dynamically, by default the node would be added after the last node, I want to add it as a first child (as first child of <total> so that I can save sorting portion at data grid. Please have a look on the code and suggest me.




protected void BtnSubmit_Click(object sender, EventArgs e)


            string xx="", yy="", zz="",
            datacable = "",
            charger = "",
            issued_by= "";
            LblSummary.Text = "";
            Lblmsg.Text = "";

Displaying + on treeview node even when no child nodes are present


I have a treeview control that is working great, except that I would like the behavior of some nodes to display the + even though no child nodes exist yet. Meaning, I want my treeview control to look like this:

- RootNode
    + Node1
    + Node2
    + Node3

However, Nodes 1, 2, and 3 do not have any child nodes. From what I can see the + or - does not display if there are no child nodes, but I would like to see the + appear even though there are no child nodes. I want to do this because I want to create the child nodes upon expanding the parent node (Node1 for example).

Is this possible?



The specified node cannot be inserted as the valid child of this node, because the specified node is


I am trying to display a portion of an xml file in a data grid.  I need to transform a number of elements to attribute to display in the grid. If i delete all of the additional elements in the xml file, my code works.  however i need those elements to remain in the XML file. So, here is what i got, maybe someone can help:

Working XML file (not useful):

<?xml version="1.0" encoding="utf-8"?>

Not working xml (need to have it work):

<?xml version="1.0" encoding="utf-8"?>

how to make a TreeNode in treeview as the 1st child node for every or specific Parent Treenode? w




How to  make a treenode  as the 1st child node for every parent node or for some specific parent nodes.

thanks in advance

about error in child node in menu



I created menu control and child nodes in .aspx page.i created childs also. where i created childs it is displayig "expand" instead of child name. the links has not working.but running it will run without error but displaying like the follwing.i didnt do any formatting simply created a menu.

Please help me to solve it.




Skip Navigation Links

Company Details
Process Owner's Details Expand Process Owner's Details

WPF Selected xml node from treeview, I want to populate a datagrid with that node and all child node

I have populated a tree view from a xml.  I know want to take the node and all children that has been selected by double clicking on the tree node and populate a data grid.

Check child node exists in XML using LINQ

In this article I will show you, how to verify the child elements/nodes are exists in the XML while selecting values from the XML using LINQ.

GridView Parent Child View with JQuery Effects

I was just checked how to add some more cool effects to the GridView control using JQuery. In this post I will display parent-child data in the GridView control with some help of the wonderful JQuery library.

Let's first populate the GridView control.

GridView control to show master-child or master-slave data, written in c#, asp.net

I previously made a master slave datagrid using Visual Studio 2003 .Net (original article) that would allow users to show data to clients using collapse and expand features. These features however did not carry over to gridview for many users. This tutorial will explaing how to create a collapsable/expandable gridview in frameworks 2.0 and higher

Display column from child table. Possible ?



I'am using dnamic entity with EF4. On a list page of a table, I would like to display a column containing information from a child table of the current element. Sample :

Order List :

Order Data | Required Date | Shipped Date | etc... | ... | Customer Name (foreign key with tostring() method override) | Customer Postal Code (Column that I want to add) |

I don't known how to do that. Is it possible ? Maybe I have to to create my own Metadata proxy that will add dynamicly a column on the MetaColumn list of the table.

Does someone have an easier or better idea ?

Thank you for any help.

How to keep the hover for Parent menu and set the selected menu item css for child menu item?



I'm using cssfriendly control adapter for menu. My asp.net menu control's datasource is a sitemap file I'm using which contains all the urls.

I have the following questions:

  1. Is there a way to keep the parent menu item hovered while hovering over the respective child menu items?
  2. Is there a way to keep the child menu item selected? I am able to set the css for the parent menu, however I was wondering if the same is possible with the child items.

Please help! Smile


Moneka Smile

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend