XML reading more details
XML reading more details
XML reading more details
XML reading more details
XML reading more details
XML reading more details XML reading more details XML reading more details XML reading more details XML reading more details XML reading more details XML reading more details XML reading more details
XML reading more details XML reading more details
XML reading more details
Go Back  Xtreme Visual Basic Talk > > > XML reading more details


Reply
 
Thread Tools Display Modes
  #1  
Old 08-11-2008, 09:01 AM
vb2008 vb2008 is offline
Regular
 
Join Date: Jan 2008
Posts: 88
Question XML reading more details


I am really new to reading XML files in VB.NET and I keep getting stuck. I am trying to figure out how see if the recipient obj_name = Truby, Dennis... If so then I would like it to look at the <inbox_list> and see if there is one in there for obj_name="Accounts Payable". This list could be huge. I am able to grab the obj_name but I am not sure how to grab the rest after that. I hope I am saying all this right :-)


Here is a sample of just that XML section of the doc


Code:
<recipient obj_nme="Truby, Dennis" >
			<identity>
				<nt_logon>
					<user domain_name="GIIFFE" account_name="dtruby" />
				</nt_logon>
			</identity>
			<email>
				<notification>
					<notify_address>dennis.truby@someplacecool.com</notify_address>
					<notify_language locale="1033" language="English (United States)" />
					<sender_notification>default</sender_notification>
				</notification>
				<email_list>
					<email_address>dennis.truby@someplacecool.com</email_address>
				</email_list>
			</email>
			<inbox_list>
				<inbox obj_name="&lt;Default&gt;" >
					<priority>50</priority>
					<allow_delete_by_owner>true</allow_delete_by_owner>
					<retain_for>forever</retain_for>
					<max_generations>keep all</max_generations>
					<notification>default</notification>
				</inbox>
				<inbox obj_name="Accounts Payable" >
					<priority>50</priority>
					<allow_delete_by_owner>true</allow_delete_by_owner>
					<retain_for>30 (days)</retain_for>
					<max_generations>keep all</max_generations>
					<notification>default</notification>
				</inbox>
				<inbox obj_name="Vendor Agreements" >
					<priority>50</priority>
					<allow_delete_by_owner>true</allow_delete_by_owner>
					<retain_for>30 (days)</retain_for>
					<max_generations>keep all</max_generations>
					<notification>default</notification>
				</inbox>
			</inbox_list>
			<security>
				<role obj_name="Cypress Admin" docuvault="GR_EDR_DV1" />
			</security>
		</recipient>



Here is my code right now that I have....


Code:
Dim m_xmld As XmlDocument
        Dim m_nodelist As XmlNodeList
        Dim m_node As XmlNode
        Dim Name As String
        Dim name2 As String

        m_xmld = New XmlDocument()
        m_xmld.Load("C:\Share\GR_Prd_DV1_address_book.xml")
        m_nodelist = m_xmld.SelectNodes("docuvault_settings/recipient_list/recipient")

        For Each m_node In m_nodelist
            Name = m_node.Attributes.GetNamedItem("obj_name").Value
            m_nodelist = m_xmld.SelectNodes("docuvault_settings/recipient_list/inbox_list/inbox")
            name2 = m_node.Attributes.GetNamedItem("obj_name").Value

            ' Show it
            TextBox1.Text = TextBox1.Text + ("Match: " & Name & " " & name2) + vbCrLf
            TextBox1.Refresh()

        Next
The code above only shows the name twice instead of showing me the name and the inbox_list value.
Could somebody please give me some help. Thank you so much.

Last edited by vb2008; 08-11-2008 at 10:05 AM.
Reply With Quote
  #2  
Old 08-11-2008, 11:09 AM
AtmaWeapon's Avatar
AtmaWeaponXML reading more details AtmaWeapon is offline
Fabulous Florist

Forum Leader
* Guru *
 
Join Date: Feb 2004
Location: Austin, TX
Posts: 9,500
Default

The problem is your second query needs to be with respect to the particular node you are working with. I could stumble through a long explanation, but code speaks louder.

First, I suggest spending some time reading about XPath. That site is just a small tutorial, but it's amazing what you can do with a well-crafted XML query.

Now let's say we have an XML file that looks like this:
Code:
<?xml version="1.0"?>
<People>
    <Person name="Alice">
        <Inboxes>
            <Inbox name="Default">
                <AllowDelete>true</AllowDelete>
                <RetainLength>Forever</RetainLength>
                <Priority>50</Priority>
            </Inbox>
            <Inbox name="Personal">
                <AllowDelete>true</AllowDelete>
                <RetainLength>30</RetainLength>
                <Priority>25</Priority>
            </Inbox>
        </Inboxes>
    </Person>
    
    <Person name="Bob">
        <Inboxes>
            <Inbox name="Default">
                <AllowDelete>true</AllowDelete>
                <RetainLength>Forever</RetainLength>
                <Priority>50</Priority>
            </Inbox>
            <Inbox name="Personal">
                <AllowDelete>true</AllowDelete>
                <RetainLength>14</RetainLength>
                <Priority>25</Priority>
            </Inbox>
        </Inboxes>
    </Person>
</People>
The following program outputs the name of each inbox that belongs to Alice:
Code:
Module Module1

    Sub Main()
        Dim xDoc As New XmlDocument()
        xDoc.Load("test.xml")

        ' Get the node for the person named "Alice"
        Dim aliceNode As XmlNode = xDoc.SelectSingleNode("People/Person[@name='Alice']")

        ' Now get all "Inbox" nodes from the node we just got
        If aliceNode IsNot Nothing Then
            Dim inboxNodes As XmlNodeList = aliceNode.SelectNodes("Inboxes/Inbox")

            Console.WriteLine("{0} inboxes for Alice:", inboxNodes.Count())
            For Each inboxNode As XmlNode In inboxNodes
                Console.WriteLine(" * {0}", inboxNode.Attributes("name").Value)
            Next
        End If

    End Sub

End Module
The first thing we want to do is ask for the Person node that has a name attribute with the value "Alice". This is what line 10 does. XPath is easiest to explain right-to-left: from the root of the document we need to tell it to look for attributes named name with a value of "Alice" on Person elements that are children of People elements:
Person/People[@name='Alice']

Now that we have that node, we want to get Inbox elements that are children of Inboxes elements for just the "Alice" Person element. You could make a larger version of the query above, but since we already have the "aliceNode" variable, why not use that?
Inboxes/Inbox

Line 14 says: "Find all Inbox elements that are children of Inboxes elements that are children of aliceNode. You could have written this query and got the same results in the end:
People/Person[@name='Alice']/Inboxes/Inbox

However, I prefer the step-by-step approach as I feel like it makes it more clear when you are getting all elements as opposed to just children of a particular node.
__________________
.NET Resources
My FAQ threads | Tutor's Corner | Code Library
I would bet money 2/3 of .NET questions are already answered in one of these three places.
Reply With Quote
  #3  
Old 08-11-2008, 11:37 AM
vb2008 vb2008 is offline
Regular
 
Join Date: Jan 2008
Posts: 88
Default

Thanks for the help but I am still stuck. I needed it to go the other way around. It needs to read all the names and find the ones that have the inbox "Vendor Agreements". If so then it needs to add their name to a textbox list. I tried to reverse it but I am still not doing something right. :-(

I am doing this....

Code:
  Dim m_xmld As XmlDocument
        Dim m_nodelist As XmlNodeList
        Dim m_node As XmlNode
        Dim name2 As String

        m_xmld = New XmlDocument()
        m_xmld.Load("C:\Share\GR_Prd_DV1_address_book.xml")
        m_nodelist = m_xmld.SelectNodes("docuvault_settings/recipient_list/recipient/inbox_list/inbox[@obj_name='Vendor Agreements']")


        For Each m_node In m_nodelist

            Dim inboxNodes As XmlNodeList = m_node.SelectNodes("docuvault_settings/recipient_list/recipient_list/recipient")
            name2 = m_node.Attributes.GetNamedItem("obj_name").Value

            TextBox1.Text = TextBox1.Text + ("Match: " & name2) + vbCrLf
            TextBox1.Refresh()

        Next
All I am getting is....
Match: Vendor Agreements
Match: Vendor Agreements
Match: Vendor Agreements
Match: Vendor Agreements
Match: Vendor Agreements
Match: Vendor Agreements
Match: Vendor Agreements
Match: Vendor Agreements

It's not showing me the name :-(

Last edited by vb2008; 08-11-2008 at 12:10 PM.
Reply With Quote
  #4  
Old 08-11-2008, 12:33 PM
vb2008 vb2008 is offline
Regular
 
Join Date: Jan 2008
Posts: 88
Default

I had no idea XML could be this hard. :-( I have been at this since 8am and its now 2pm :-0

Last edited by vb2008; 08-11-2008 at 12:41 PM.
Reply With Quote
  #5  
Old 08-11-2008, 12:51 PM
AtmaWeapon's Avatar
AtmaWeaponXML reading more details AtmaWeapon is offline
Fabulous Florist

Forum Leader
* Guru *
 
Join Date: Feb 2004
Location: Austin, TX
Posts: 9,500
Default

Ahhh, the "big fat XPath" approach will work here, but you've got to do some work. You want the name of the recipient, but you're at the level of the inbox element. It's a problem, but not a big one. I'm pretty sure you can arrive at either of the solutions I'll discuss from where you are.

One approach might be to select all recipient elements, then test if they have a child Inbox node with the appropriate name. This is similar to what I did the first time, with some minor changes. First, use SelectNodes with "docuvault_settings/recipient_list/recipient" to get all of the recipients. Now, for each node that returns, call SelectSingleNode with "inbox_list/inbox[@obj_name='Vendor Agreements']". This is either going to return a node or Nothing; if it returns Nothing you know that recipient doesn't have an inbox with that name.

An alternative approach that I think is better is to use your XPath statement as-is to get the list of all inbox elements with the attribute you want; then for each of these, use the ParentNode property to get back to the recipient node. You could also use the parent axis specifier of XPath to specify the path to the correct node:
parent::inbox_list/parent::recipient

This says, "Starting at me, find the parent named "recipient", then look for its parent named "inbox_list". You can use the ".." shortcut for the parent axis as well:
../..
__________________
.NET Resources
My FAQ threads | Tutor's Corner | Code Library
I would bet money 2/3 of .NET questions are already answered in one of these three places.
Reply With Quote
  #6  
Old 08-11-2008, 12:56 PM
vb2008 vb2008 is offline
Regular
 
Join Date: Jan 2008
Posts: 88
Default

Oh lord.....
Reply With Quote
  #7  
Old 08-11-2008, 01:11 PM
vb2008 vb2008 is offline
Regular
 
Join Date: Jan 2008
Posts: 88
Default

Well here is what I came up with but it returns nothing :-(

Code:
  Dim m_xmld As XmlDocument
        Dim m_nodelist As XmlNodeList
        Dim m_node As XmlNode
        Dim Name As String
        Dim xDoc As New XmlDocument()

        m_xmld = New XmlDocument()
        m_xmld.Load("C:\Share\GR_Prd_DV1_address_book.xml")
        m_nodelist = m_xmld.SelectNodes("docuvault_settings/recipient_list/recipient")

        For Each m_node In m_nodelist
            Dim aliceNode As XmlNode = xDoc.SelectSingleNode("inbox_list/inbox[@obj_name='Vendor Agreements']")

            If aliceNode IsNot Nothing Then
                ' Do nothing
            Else
                ' Show it
                Name = m_node.Attributes.GetNamedItem("obj_name").Value
                TextBox1.Text = TextBox1.Text + ("Match: " & Name) + vbCrLf
                TextBox1.Refresh()
            End If
        Next
And here is is what the information could look like under a name. I am looking to find all people who have a inbox called "Vendor Agreements". If so I want to add their name to textbox1.

Code:
 <recipient obj_nme="Truby, Dennis" >
			<identity>
				<nt_logon>
					<user domain_name="GIIFFE" account_name="dtruby" />
				</nt_logon>
			</identity>
			<email>
				<notification>
					<notify_address>dennis.truby@someplacecool.com</notify_address>
					<notify_language locale="1033" language="English (United States)" />
					<sender_notification>default</sender_notification>
				</notification>
				<email_list>
					<email_address>dennis.truby@someplacecool.com</email_address>
				</email_list>
			</email>
			<inbox_list>
				<inbox obj_name="&lt;Default&gt;" >
					<priority>50</priority>
					<allow_delete_by_owner>true</allow_delete_by_owner>
					<retain_for>forever</retain_for>
					<max_generations>keep all</max_generations>
					<notification>default</notification>
				</inbox>
				<inbox obj_name="Accounts Payable" >
					<priority>50</priority>
					<allow_delete_by_owner>true</allow_delete_by_owner>
					<retain_for>30 (days)</retain_for>
					<max_generations>keep all</max_generations>
					<notification>default</notification>
				</inbox>
				<inbox obj_name="Vendor Agreements" >
					<priority>50</priority>
					<allow_delete_by_owner>true</allow_delete_by_owner>
					<retain_for>30 (days)</retain_for>
					<max_generations>keep all</max_generations>
					<notification>default</notification>
				</inbox>
			</inbox_list>
			<security>
				<role obj_name="Cypress Admin" docuvault="GR_EDR_DV1" />
			</security>
		</recipient>

Last edited by vb2008; 08-11-2008 at 01:23 PM.
Reply With Quote
  #8  
Old 08-11-2008, 01:25 PM
AtmaWeapon's Avatar
AtmaWeaponXML reading more details AtmaWeapon is offline
Fabulous Florist

Forum Leader
* Guru *
 
Join Date: Feb 2004
Location: Austin, TX
Posts: 9,500
Default

Please take some time to think about the problem instead of pasting it in as soon as something doesn't work. Take a look at this line:
Code:
Dim aliceNode As XmlNode = xDoc.SelectSingleNode("inbox_list/inbox[@obj_name='Vendor Agreements']")
Do you want to get the inbox_list child of the document root (what you have here), or did you mean to get the inbox_list child of m_node?

In other words, the code you posted would only work if your document looks like this:
Code:
<?xml version=1.0>
<docuvault_settings>
    <recipient_list>
        <recipient name="..." />
    </recipient_list>
</docuvault_settings>
<inbox_list>
        <inbox obj_name="Vendor Agreements" />
</inbox_list>
__________________
.NET Resources
My FAQ threads | Tutor's Corner | Code Library
I would bet money 2/3 of .NET questions are already answered in one of these three places.
Reply With Quote
  #9  
Old 08-11-2008, 01:36 PM
vb2008 vb2008 is offline
Regular
 
Join Date: Jan 2008
Posts: 88
Default

Right so I would think it would be like this....

Code:
 Dim aliceNode As XmlNode = m_node.SelectSingleNode("inbox_list/inbox[@obj_name='Vendor Agreements']")
Which I tried but when I do that it lists every single name in the XML file rather then just the ones with the inbox Vendor Agreements.

Not trying to be a pain I just do not understand I guess. I will pass it off I guess since I just do not understand it.

Thanks for the help anyway.
Reply With Quote
  #10  
Old 08-11-2008, 01:41 PM
AtmaWeapon's Avatar
AtmaWeaponXML reading more details AtmaWeapon is offline
Fabulous Florist

Forum Leader
* Guru *
 
Join Date: Feb 2004
Location: Austin, TX
Posts: 9,500
Default

Oh you got your logic reversed, too. Take a look at this and see if you can't spot the problem.

This is how the situation really is:
Code:
If aliceNode IsNot Nothing Then
    ' The node has an inbox named "Vendor Agreements"; do whatever with it
Else
    'The node does not have an inbox named "Vendor Agreements"
End If
Compare it to how your code is written. There's an important difference between what you are doing and this.
__________________
.NET Resources
My FAQ threads | Tutor's Corner | Code Library
I would bet money 2/3 of .NET questions are already answered in one of these three places.
Reply With Quote
  #11  
Old 08-11-2008, 02:22 PM
vb2008 vb2008 is offline
Regular
 
Join Date: Jan 2008
Posts: 88
Default

Ok I see. Its working now. :-)

This whole XML thing takes some getting used to. Thank you for all the help.
Reply With Quote
  #12  
Old 08-11-2008, 02:25 PM
vb2008 vb2008 is offline
Regular
 
Join Date: Jan 2008
Posts: 88
Default

One other question....

How would you go about doing this....
Code:
Dim aliceNode As XmlNode = m_node.SelectSingleNode("inbox_list/inbox[@obj_name='Vendor Agreements']")
But instead of saying obj_name='Vendor Agreements' have it = something like textbox1 so the user could imput a value on the form?

Thanks!
Reply With Quote
  #13  
Old 08-12-2008, 08:09 AM
vb2008 vb2008 is offline
Regular
 
Join Date: Jan 2008
Posts: 88
Default

I still have not figured this part out... Any direction?

Thanks!
Reply With Quote
  #14  
Old 08-12-2008, 08:16 AM
wayneph's Avatar
waynephXML reading more details wayneph is offline
Web Junkie

Retired Moderator
* Expert *
 
Join Date: Apr 2004
Location: D/FW, Texas, USA
Posts: 8,393
Default

You can either concatenate the value from the Text Box into the String, or use somthing like the String.Format() method to add the value to the middle.

If you can figure out the XML part, this should be easy.
__________________
-- wayne, MSSM Retired
> SELECT * FROM users WHERE clue > 0
0 rows returned
Reply With Quote
  #15  
Old 08-12-2008, 08:38 AM
vb2008 vb2008 is offline
Regular
 
Join Date: Jan 2008
Posts: 88
Default

Figured it out :-)

Dim aliceNode As XmlNode = m_node.SelectSingleNode("inbox_list/inbox[@obj_name='" & Search_Value_1.Text & "']")

Thanks!
Reply With Quote
  #16  
Old 08-12-2008, 09:17 AM
vb2008 vb2008 is offline
Regular
 
Join Date: Jan 2008
Posts: 88
Question

Well I think I am starting to understand some of this now.
I am stuck on one other thing....

Here is how I am searching for what ever the user types in for a search value in the application....

Code:
m_xmld = New XmlDocument()
        m_xmld.Load("C:\Share\GR_Prd_DV1_address_book.xml")
        m_nodelist = m_xmld.SelectNodes("docuvault_settings/recipient_list/recipient")
        For Each m_node In m_nodelist

            Dim aliceNode As XmlNode = m_node.SelectSingleNode("inbox_list/inbox[@obj_name='" & Search_Value_1.Text & "']")

            If aliceNode IsNot Nothing Then
                ' Show it
                Name = m_node.Attributes.GetNamedItem("obj_name").Value

                Priority = m_node.Attributes.GetNamedItem("priority").Value

                Report_Screen.Rows.Add(New String() {Name, Search_Value_1.Text, Priority})

What I am trying to do now though is to read the line of XML that is right below that called priority.

Code:
<inbox obj_name="Vendor Agreements">
<priority>50</priority>
So far no luck.


I even thought maybe it was something like this....

Code:
Dim aliceNode As XmlNode = m_node.SelectSingleNode("inbox_list/inbox[@obj_name='" & Search_Value_1.Text & "']" & "inbox_list/priority='" & Priority_Selection_1.Text & "']")
But of course that did not work. Am I even on the right track?

Last edited by vb2008; 08-12-2008 at 09:27 AM.
Reply With Quote
  #17  
Old 08-12-2008, 09:39 AM
AtmaWeapon's Avatar
AtmaWeaponXML reading more details AtmaWeapon is offline
Fabulous Florist

Forum Leader
* Guru *
 
Join Date: Feb 2004
Location: Austin, TX
Posts: 9,500
Default

Please spend some time reading the documentation for the classes you are using and thinking about the problem. You're not really showing any attempt to understand this; did you look at the string in the debugger? If the user searches for "search" and "50", you'll end up with an XPath query that looks like this:
inbox_list/inbox[@obj_name='search']inbox_list/priority='50']
Can you see how that string might be wrong?

After you execute the query, aliceNode is the XML node <inbox>. This has a child element named "priority" that you want to get. You could use the ChildNodes property of aliceNode to access the children, or you could use an XPath query to get the priority node.

Take a look at the code and see how it works. First, you get the recipient nodes. Then, for each recipient, you look for a particular inbox node. Now, you want to get a particular node that's a child of the inbox node. How do you think you might do so?
__________________
.NET Resources
My FAQ threads | Tutor's Corner | Code Library
I would bet money 2/3 of .NET questions are already answered in one of these three places.
Reply With Quote
  #18  
Old 08-12-2008, 09:47 AM
vb2008 vb2008 is offline
Regular
 
Join Date: Jan 2008
Posts: 88
Default

Do you have any good links to read on this? I have been teaching myself all this and trying to understand it.

Thank you.
Reply With Quote
  #19  
Old 08-12-2008, 10:02 AM
vb2008 vb2008 is offline
Regular
 
Join Date: Jan 2008
Posts: 88
Default

HEY I THINK I GOT IT!!!! :-))))


Code:
Dim aliceNode As XmlNode = m_node.SelectSingleNode("inbox_list/inbox[@obj_name='" & Search_Value_1.Text & "' and priority ='" & Priority_Selection_1.Text & "']")
Is that how you would do it? It seems to work well. I learned it from here...
http://support.microsoft.com/kb/317069
Reply With Quote
  #20  
Old 08-13-2008, 09:35 AM
vb2008 vb2008 is offline
Regular
 
Join Date: Jan 2008
Posts: 88
Question

So I am trying to figure out a new part now but I am getting stuck once again and yes I have been reading up on things and I think I know what my problem is I am just not sure how to fix it. Below is the XML I am trying to read. I need to be able to have the user type in a user they are looking for which is assigned to the Role_Search_Value_1.Text box. Then when it finds that user, I want to capture the permissions for that user. So far I have not had any luck in capturing the permission. I think it's because I am not getting down to the permission area and I am not sure why.

XML file
Code:
<?xml version="1.0" ?>
<docuvault_settings>
	<role_list>
		<role obj_name="Logistics" >
			<role_type>master_role</role_type>
			<members>
				<user domain_name="GFSPROD" account_name="aclippert" permission="000F" />
				<user domain_name="GFSPROD" account_name="afarner" permission="000F" />
				<user domain_name="GFSPROD" account_name="akincaid" permission="000F" />
				<user domain_name="GFSPROD" account_name="akruitho" permission="000F" />
				<user domain_name="GFSPROD" account_name="arossow" permission="000F" />
				<user domain_name="GFSPROD" account_name="awhitmor" permission="000F" />
				<user domain_name="GFSPROD" account_name="bdillet" permission="000F" />
				<user domain_name="GFSPROD" account_name="bjohnso4" permission="000F" />
				<user domain_name="GFSPROD" account_name="bkaczano" permission="000F" />
				<user domain_name="GFSPROD" account_name="blackmer" permission="000F" />
				<user domain_name="GFSPROD" account_name="bporritt" permission="000F" />
				<user domain_name="GFSPROD" account_name="bschneider" permission="000F" />
				<user domain_name="GFSPROD" account_name="btuinst2" permission="000F" />
				<user domain_name="GFSPROD" account_name="cainsworth" permission="000F" />
				<user domain_name="GFSPROD" account_name="cjenks" permission="000F" />
				<user domain_name="GFSPROD" account_name="cpierson" permission="000F" />
				<user domain_name="GFSPROD" account_name="crosinsk" permission="000F" />
				<user domain_name="GFSPROD" account_name="cseay" permission="000F" />
				<user domain_name="GFSPROD" account_name="cwoodcraft" permission="000F" />
				<user domain_name="GFSPROD" account_name="dclark" permission="000F" />
				<user domain_name="GFSPROD" account_name="dhozak" permission="000F" />
				<user domain_name="GFSPROD" account_name="ehoebeke" permission="000F" />
				<user domain_name="GFSPROD" account_name="ejasinsk" permission="000F" />
				<user domain_name="GFSPROD" account_name="emathieu" permission="000F" />
				<user domain_name="GFSPROD" account_name="evanhofw" permission="000F" />
				<user domain_name="GFSPROD" account_name="ewright" permission="000F" />
				<user domain_name="GFSPROD" account_name="jashley" permission="000F" />
				<user domain_name="GFSPROD" account_name="jblevins" permission="000F" />
				<user domain_name="GFSPROD" account_name="jborst" permission="000F" />
				<user domain_name="GFSPROD" account_name="jfallot" permission="000F" />
				<user domain_name="GFSPROD" account_name="jfanco" permission="000F" />
				<user domain_name="GFSPROD" account_name="jfisher" permission="000F" />
				<user domain_name="GFSPROD" account_name="jmcinty2" permission="000F" />
				<user domain_name="GFSPROD" account_name="jostrand" permission="000F" />
				<user domain_name="GFSPROD" account_name="jsalmon" permission="000F" />
				<user domain_name="GFSPROD" account_name="jtroutman" permission="000F" />
				<user domain_name="GFSPROD" account_name="jwierenga" permission="000F" />
				<user domain_name="GFSPROD" account_name="jwyns" permission="000F" />
				<user domain_name="GFSPROD" account_name="kduval" permission="000F" />
				<user domain_name="GFSPROD" account_name="kkrzyzan" permission="000F" />
				<user domain_name="GFSPROD" account_name="krilett" permission="000F" />
				<user domain_name="GFSPROD" account_name="ktolliver" permission="000F" />
				<user domain_name="GFSPROD" account_name="lbadersn" permission="000F" />
				<user domain_name="GFSPROD" account_name="ldow" permission="000F" />
				<user domain_name="GFSPROD" account_name="lminasol" permission="000F" />
				<user domain_name="GFSPROD" account_name="mbattagl" permission="000F" />
				<user domain_name="GFSPROD" account_name="mbury" permission="000F" />
				<user domain_name="GFSPROD" account_name="mjenks" permission="000F" />
				<user domain_name="GFSPROD" account_name="mponstei" permission="000F" />
				<user domain_name="GFSPROD" account_name="mroberts" permission="000F" />
				<user domain_name="GFSPROD" account_name="mskowron" permission="000F" />
				<user domain_name="GFSPROD" account_name="pdodge" permission="000F" />
				<user domain_name="GFSPROD" account_name="rblue" permission="000F" />
				<user domain_name="GFSPROD" account_name="rborst" permission="000F" />
				<user domain_name="GFSPROD" account_name="rcurtis" permission="000F" />
				<user domain_name="GFSPROD" account_name="rdemann" permission="000F" />
				<user domain_name="GFSPROD" account_name="rkusmier" permission="000F" />
				<user domain_name="GFSPROD" account_name="rpearson" permission="000F" />
				<user domain_name="GFSPROD" account_name="rschuur" permission="000F" />
				<user domain_name="GFSPROD" account_name="rvanoverloop" permission="000F" />
				<user domain_name="GFSPROD" account_name="sbeld" permission="000F" />
				<user domain_name="GFSPROD" account_name="scarlstr" permission="000F" />
				<user domain_name="GFSPROD" account_name="scooper" permission="000F" />
				<user domain_name="GFSPROD" account_name="selgersm" permission="000F" />
				<user domain_name="GFSPROD" account_name="shicks" permission="000F" />
				<user domain_name="GFSPROD" account_name="spycraft" permission="000F" />
				<user domain_name="GFSPROD" account_name="ssperling" permission="000F" />
				<user domain_name="GFSPROD" account_name="steveadams" permission="000F" />
				<user domain_name="GFSPROD" account_name="swright4" permission="000F" />
				<user domain_name="GFSPROD" account_name="tdrier" permission="000F" />
				<user domain_name="GFSPROD" account_name="tfoxcole" permission="000F" />
				<user domain_name="GFSPROD" account_name="theemstra" permission="000F" />
				<user domain_name="GFSPROD" account_name="tkwiatko" permission="000F" />
				<user domain_name="GFSPROD" account_name="tmartell" permission="000F" />
				<user domain_name="GFSPROD" account_name="tneifert" permission="000F" />
				<user domain_name="GFSPROD" account_name="twoody" permission="000F" />
			</members>
So for example if I wanted to search for the user 'akincaid' that would be assigned to the Role_Search_Value_1.text box and should return the Logistics and 000F.

Here is my code right now....
Code:
 m_xmld = New XmlDocument()
        m_xmld.Load("C:\Share\GR_Prd_DV1_roles.xml")
        m_nodelist = m_xmld.SelectNodes("docuvault_settings/role_list/role")
        For Each m_node In m_nodelist

            Dim aliceNode As XmlNode = m_node.SelectSingleNode("members/user[@account_name='" & Role_Search_Value_1.Text & "']")

            If aliceNode IsNot Nothing Then
                Name = m_node.Attributes.GetNamedItem("obj_name").Value
                Permission = m_node.Attributes.GetNamedItem("permission").Value
Am I right or way off? I mean is that why I am getting a 'NullReferenceException was unhandled" for....
Code:
Permission = m_node.Attributes.GetNamedItem("permission").Value
I am trying really hard to grasp this XML reading. It can be a bit tricky I am learning.

Thanks in advance.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
XML reading more details
XML reading more details
XML reading more details XML reading more details
XML reading more details
XML reading more details
XML reading more details XML reading more details XML reading more details XML reading more details XML reading more details XML reading more details XML reading more details
XML reading more details
XML reading more details
 
XML reading more details
XML reading more details
 
-->