Help Reading A XML File In VB.NET

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vb2008
    New Member
    • Aug 2008
    • 4

    Help Reading A XML File In VB.NET

    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_Val ue_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_Val ue_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 'NullReferenceE xception 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.
  • vb2008
    New Member
    • Aug 2008
    • 4

    #2
    Any help please? I am really stuck here. :-(

    Comment

    • joedeene
      Contributor
      • Jul 2008
      • 579

      #3
      you might have better results/help posting in the proper forum, based on your title this question should be in the .NET forum. so i'd recommend reading the site's rules http://bytes.com/forum/faq.php?faq=posting_guidelines and in the meantime im gonna ask a moderator to redirect/move the forum... but i'm sorry i really can't help you, im not experienced in that area, by the way what language are you using ?

      Comment

      • vb2008
        New Member
        • Aug 2008
        • 4

        #4
        Oh sorry. It's VB.NET.

        Thanks!

        Comment

        Working...