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

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Getting XML nodes out.

Posted By:      Posted Date: October 18, 2010    Points: 0   Category :ASP.Net


i have an xml where there could be one book or multiples.

i'm trying to get the info out, this is what i have now:


            Dim doc As New XmlDocument()
            Dim couponCode As String

            doc.Load(New StringReader(Me.Cart1.XmlDoc.InnerXml))
            Dim productNodes As XmlNodeList
            Dim baseDataNodes As XmlNodeList
            Dim bFirstInRow As Boolean

            productNodes = doc.GetElementsByTagName("books")
            For Each productNode In productNodes
                baseDataNodes = productNode.ChildNodes
                bFirstInRow = True
                For Each baseDataNode As XmlNode In baseDataNodes 
 lblMessage.Text += baseDataNode.SelectSingleNode("//ups").InnerText lblMessage.Text += "<br/>" lblMessage.Text += baseDataNode.SelectSingleNode("//name").InnerText Next Next Catch generatedExceptionName As Exception End Try

my xml looks like this:




View Complete Post

More Related Resource Links

Site map with > 150 nodes


Based on the turotial, it mention that if my sitemap have more than 150 node it will have impact on the performance.

Is the any option if i do have more than 150 mode to include in the xml file (with security node trimming=true, where i inserted role=ABC in every node.)

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?

Child nodes not allowed.


Hi everyone.

I'm positive that, by now, a lot of people have run into this problem but even with all the forum posts with great answers, I still can't seem to get to the bottom of it. Here are some specs:

  • Windows Server 2008
  • Visual Studio 2008 x86

So here's the issue:

I have VS2008 installed on the server listed above. This is our development server and everything is created and tested here. I have created an asp.net application, tested it on the dev. environment and everything works great. When I try to migrate this application up to our Quality Assurance environment (which is Windows Server 2003), I get the error in the subject title.

I've read many things that can be the cause of this and I'm positive that I know 2 ways of fixing it. One is from this post: Simple web site problem on Vista, related to <providerOption>, and the other is making sure 3.5 framework is at least installed on the server in question. There are 2 reasons why I'm unable to use these 2 methods:

  • The patches from DVD that I'm supposed to install won't let me install them. Upon double clicking I recieve a message saying the "Update is not applicable to your computer"
  • I don't have permission to install 3.5 frame

WPF- Treeview--How to add child nodes-- a Bizzare problem-- plz help

so here it is.... in WPF ... Treeview control -- i can add nodes under root node, using XAML code  which is static i hav to add the nodes, using C# code which is dynamic. For Example: Menu Table MenuId       Name       ParentId     1           Country         0     2           India             1     3           USA              1     4           AP                2     5           UP                2     6           California      3     7           Newyork       3 In my C# Code i took a class file in that, i declared the menu() method of type DataTable. Method menu() :- I created a temptable (using DATATABLE CLASS) with same fields(using CLONE()) and filled it with MENU table data and returned that temptable. So now i have data with me. Based on ParentID i can retrieve the child values. but how to add those values to TREEVIEW as its ITEMS There is no---> " treeview1.Items[0].Items.Add() " thing in WPF--- n its creating problem to me. Hw can i do dat...? i dnt knw which Methods , Properties , Classes  to Use. Ex:       + COUNTRY             + INDIA                    AP                    UP              +USA                    Lusiana                    Nwyrk Please help. Thank you. Beginner in WPF..... VENU.Beginner in WPF.......VENU

Multiple Child Nodes with For XML Path

I am trying to generate this format of xml and having difficulties because of the properties section. I can have unlimited number of properties and "For XML" tells me it can't generate the same node "Properties/@Name". I have tried several methods online, but can't seem to get it to work. OptionLists> <OptionList Name="Functions"> <Option Value="L9496"> <Properties Name="Description" Value="L9496 - Privacy Lock With Indicator" /> <Properties Name="Locked" Value="False" /> </Option> <Option Value="LV9040" /> <Option Value="L9485" /> </OptionList> </OptionLists>   My SQL currently looks like this: SELECT 'Functions' as '@Name', ( Select coalesce(nullif(No_,''),'NONE') "Option/@Value", Case NO_ when isNull(nullif(NO_,''),null) Then 1 Else 99 END "Option/@Order", 'TRUE' "Option/@Visible", 'FALSE' "Option/@Locked", '' "Option/@ToolTip", '' "Option/@ImageLink", '' "Option/@InfoMessage", 'QtySensitive' "Option/Properties/@Name", Case [Quantity Sensitive] When 0 Then 'False' When 1 Then 'True' End "Option/Propert

How to add custom nodes for a treeview

Hi the actual procees of my work is initially i will have a root node for a treeview. If i right click on that i will have a context menu with some options. If i select add new from that i will add a text file as child node to the root node. This works fine . After adding that text file i would like to add a child node under that text file..   The over all flow will be Initially when page loads my treeview will be with a single rootnode   ACH If i add a text file i would like to show my treeview as follows   ACH |-> some.txt    |->A( Child for some.txt)        |->B(child for  A)             |->C(Child for B)   Up to A i was succeded but i do not know how to add the remaining also i would like to set image index for the custom child nodes added  

xml nodes query on DataContractSerializer string

Hi I need to get a table from this xml, I have some experience using nodes but am getting nowhere on this string.  It is produced from DataContractSerializer on a list with one of the columns a dictionary.  Any help will be much appreciated!  declare @xml xml = ' <ArrayOfArmorDeviceBase xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://server.armor.com/contract/data">   <ArmorDeviceBase xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/" z:Id="i1" i:type="ArmorSimpleDevice">     <Id>5000</Id>     <SiteId>0</SiteId>     <SourceSystem>Armor</SourceSystem>     <DataGroups xmlns:d3p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">       <d3p1:KeyValueOfstringDeviceDataGroupBaseRRFhSxY9>         <d3p1:Key>CommunicationStatus</d3p1:Key>         <d3p1:Value xmlns:d5p1="http://server.armor.com/contract/data/ControllerStatus" i:type="d5p1:CommunicationStatus">           <Ticks>0</Ticks>           <d5p1:Status>Disco

Select nodes based on element innertext

This should be easy...hoping someone could have a look & see what wrong with my code. I'm simply trying to loop through an xml document & grab multiple nodes if a specific element contains specific text. So if my xml looks like this: <Settings><Document>        <FriendlyName>The Big One</FriendlyName>        <ID>8ae3428b-f1f2-4b94-a65c-2c8e24f660c8</ID>        <Post>True</Post>        <Department>Collections</Department>        <Category>Forms</Category>        <Audience></Audience>        <Link Type="Page" Target=""><![CDATA[]]></Link>        <Keywords></Keywords>    </Document></Settings> So my requirement is: For each element, If FriendlyName contains "Big", get the inntertext of FriendlyName, Department, Category, Link and pipe them together like this: "The Big One | Collections | Forms | Link"   It looks like I'm having problems with the If statement, if I remove it I'll get every

Selecting only required nodes

Hi All, I'm new to working with XML and was wondering if anyone here could give me a hand or point me in the direction of decent reading material. Baically I have an xml document with a lot of content. I have only provided some of this data below, and highlighted content which i need to access in my vb.net code behind.  <?xml version="1.0" encoding="iso-8859-1"?> <ProgressXMLExport xmlns:dt='urn:schemas-microsoft-com:datatypes' Tables='Case' Query=''> <case_details> <CaseField Name="case.key"><![CDATA[468140]]></CaseField> <CaseField Name="Client.Title"><![CDATA[Ms]]></CaseField> <CaseField Name="Client.Forename"><![CDATA[Carol]]></CaseField> <CaseField Name="Client.Name"><![CDATA[Lloyd]]></CaseField> <CaseField Name="File Opened.Date"><![CDATA[20/05/2008]]></CaseField> <CaseField Name="Accident Dte.Date"><![CDATA[20/05/2008]]></CaseField> <CaseField Name="TOTAL COST TO DATE.Value"><![CDATA[1923.70]]></CaseField> </case_details> <__Record /> <history.case_no><![CDATA[468140]]></history.case_no> <history.created_date&

WPF TreeView child nodes - collection is not a member of the first level nodes object



I was wondering if i could use a TreeView to display data from 2 separate collections where both collections are members of the same object. For example i have a view model that has 2 observable collections:



Each model has a property Brand which specifies the brand for each model. What i want to do is bind the first level to the Brands collection and the second level to the Models collection and specify a filter.

Thanks in advance.

Treenodes keep reference after Nodes.copyTo from treeview


I have a treeview with nodes. I want to keep a copy of the original nodes before editing. After I made a copy i delete some subnodes, but it is also deleted in my array. Strange?

Any ideas??

Thanks, Cadsjo


    public Form1()

private TreeNode[] _storeArray;
private List<TreeNode> _storeList;

private void Form1_Load(object sender, EventArgs e)

Console.WriteLine("In stor

add child nodes to treeview control

 private void updateTreeView(IMongoCollection one)
      ICursor coll= one.FindAll();
      int count=0;
      foreach (Document document in coll.Documents)
       TreeNode mynode= treeView1.Nodes.Add(count.ToString());
       enumerateValues(document.GetEnumerator(), mynode);



    private void enumerateValues(IEnumerator<KeyValuePair<string, object>> iEnumerator, TreeNode parentnode)
      //TreeNode childnode = parentnode.Add(iEnumerator.Current.Key.ToString());
       if(iEnumerator is IEnumerable)
         // ADD THE KEY
         TreeNode childNode = parentnode.Nodes.Add(iEnumerator.Current.Key);

         enumerateValues(iEnumerator.Current.Value, childNode);
         /// add the value

Collapse all the nodes on load in XSLT


I have created an xslt file to format xml file. My ewquirement is to show that xml in a tree format. That I have achieved. But, when I click on the root node, it will show all subnodes(which are by default expanded). I want all subnodes need to be collapsed by default on clicking of root node. Similarly, on clicking of subnode, it should be expanded with contents and subnodes of this node to be collapsed by default and so on.

How can I achieve this? 

Sitemap: why can't sub nodes further restrict role access?


I have a menu in my application (created from the sitemap) which I want available to two user roles.  However, there are items on that menu, I want available only to one role or the other.  So I have created the following in my sitemap.

	  <siteMapNode title="My Account" roles="TimeUser, Client" >
		  <siteMapNode title="My Profile" url="~/TimeTracker/ClientUserProfile.aspx" description="" roles="Client" />
		  <siteMapNode title="My Profile" url="~/TimeTracker/EmpProfile.aspx" description="" roles="TimeUser" />
		  <siteMapNode title="Change Password" url="~/TimeTracker/EmpChangePassWord.aspx" description="" roles="TimeUser, Client" />

Essentially, I want employees with the "TimeUser" role to see the "My Profile" link that goes to the EmpProfile.aspx page, but not the link to the client profile page.  However, when an employee logs in, they see both.  I am guessing this may be because the "My Account" node which contains them allows both roles.  Is there a way around this without duplicating the "My Account" node?

Renaming Xml Nodes



    i need to rename the xml nodes.

for eg:

        My xml format













here i want to rename

<Title> to <Titles>

<Authors> to <customer>

<Authorsdetails> to <details>

plz guide me...


Multiple nodes with the same URL


I'm trying to build a sqlsitemapprovider. I gets the error "Multiple nodes with the same URL" I can't figure out what I'm doing wrong, I hoipe anyone can help me. There is no duplicate url in the db.

public override SiteMapNode BuildSiteMap()
        lock (this)
            // Don't rebuild the map unless needed.
            // If your site map changes often, consider using caching.
            if (rootNode == null)
                // Start with a clean slate.
            // Get all the data (using provider-agnostic code).
            DbProviderFactory provider = DbProviderFactories.GetFactory(providerName);
            // Use this factory to create a connection.
            DbConnection con = provider.CreateConnection();
            con.ConnectionString = connectionString;
            // Create the command.
            DbCommand cmd = provider.CreateCommand();
            cmd.CommandText = storedProcedure;
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Connection = con;
            // Create the DataAdapter.
            DbDataAdapter adapter = provider.CreateDataAdapter();
            adapter.SelectCommand = cmd;
            // Get the results in a DataS
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