Advertisement

08.18.2008 at 06:10AM PDT, ID: 23656172
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.4

Not Getting Values From XML Reading In VB.NET

Asked by vb2009 in .NET, Microsoft Visual Basic.Net, .Net Editors & IDEs

Tags:

I am having a issue where when reading a XML file certain nods may or may not be present that the code might be looking for via the value given by the user.  The problem is with my code below its not grabbing the values if they are there or not.  I am not getting any errors, I am just not getting the values.

<?xml version="1.0" ?>
<docuvault_settings>
<device_list>
<device obj_name="BO Hold">
<general>
  <device_dll><none></device_dll>
  <link_dll><none></link_dll>
  <num_of_buffers>3</num_of_buffers>
  <block_size>16384</block_size>
  <page_queue_limit>6</page_queue_limit>
  <format obj_name="<none>" use_auto_format="false" />
  <banner obj_name="<none>" always_use_this_banner="false" />
  <color>black/white</color>
  <orientation>simplex</orientation>
  <output_preference>device dll only</output_preference>
  </general>
<time>
  <job_timeout retain_for="24:00(hr:min)" purge_after="never" />
  <device_timeout switch_after="2:00(hr:min)" alt_device="<none>" />
  </time>
 <security>
  <role obj_name="420 Operators" docuvault="GR_Prd_DV1" />
  <role obj_name="Cypress Admin" docuvault="GR_Prd_DV1" />
  <role obj_name="Help Desk" docuvault="GR_Prd_DV1" />
  </security>
  </device>
<device obj_name="C6500">
<general>
  <model>Danka-Sun</model>
  <description>Printer with Punch and Binder</description>
  <host>10.251.8.118</host>
  <unit>order_guide</unit>
  <device_dll>DigiMaster</device_dll>
  <link_dll>lpd_o</link_dll>
  <dialects>ignore_stock no_pjl merge_job</dialects>
  <num_of_buffers>3</num_of_buffers>
  <block_size>16384</block_size>
  <page_queue_limit>6</page_queue_limit>
  <stock_sub obj_name="OG-Cover-Sub(GR_Prd_DV1:2)" />
  <format obj_name="<none>" use_auto_format="false" />
  <banner obj_name="<none>" always_use_this_banner="false" />
  <color>black/white</color>
  <orientation>duplex</orientation>
  <output_preference>device dll only</output_preference>
  </general>

As you can see the first one does not contain nods such as host and so on.  This is a big XML file and it can be like this through the whole thing.  My code is below.  The part throwing the trouble is...
 Name = m_node.ParentNode.Attributes.GetNamedItem("obj_name").Value
            If Not m_node.ParentNode.Attributes.GetNamedItem("description") Is Nothing Then Description = m_node.ParentNode.Attributes.GetNamedItem("description").Value
            If Not m_node.ParentNode.Attributes.GetNamedItem("host") Is Nothing Then Host = m_node.ParentNode.Attributes.GetNamedItem("host").Value
            If Not m_node.ParentNode.Attributes.GetNamedItem("unit") Is Nothing Then unit = m_node.ParentNode.Attributes.GetNamedItem("unit").Value
            If Not m_node.ParentNode.Attributes.GetNamedItem("device_dll") Is Nothing Then Device = m_node.ParentNode.Attributes.GetNamedItem("device_dll").Value
            If Not m_node.ParentNode.Attributes.GetNamedItem("link_dll") Is Nothing Then Link = m_node.ParentNode.Attributes.GetNamedItem("link.dll").Value

It is not returning any of these values in the datagrid.  My complete code is below.
Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
Dim m_xmld As XmlDocument
        Dim Name As String
        Dim Description As String
        Dim unit As String
        Dim Device As String
        Dim Link As String
        Dim Host As String
 
        ' Set Grid
        Dim Report_Screen As New DataTable()
        Report_Screen.Clear()
 
        Report_Screen.Columns.Add(New DataColumn("Name", GetType(String)))
        Report_Screen.Columns.Add(New DataColumn("Match Criteria", GetType(String)))
        Report_Screen.Columns.Add(New DataColumn("Discription", GetType(String)))
        Report_Screen.Columns.Add(New DataColumn("Device DLL", GetType(String)))
        Report_Screen.Columns.Add(New DataColumn("Link DLL", GetType(String)))
        Report_Screen.Columns.Add(New DataColumn("Host", GetType(String)))
        Report_Screen.Columns.Add(New DataColumn("Unit", GetType(String)))
 
        Device_Status.Text = "Searching..."
        Device_Status.Refresh()
 
        m_xmld = New XmlDocument()
        m_xmld.Load("C:\Share\GR_Prd_DV1_devices.xml")
        For Each m_node As XmlNode In m_xmld.SelectNodes("docuvault_settings/device_list/device/general[model='" & Devices_Search_Value_1.Text & "']")
 
            Name = m_node.ParentNode.Attributes.GetNamedItem("obj_name").Value
            If Not m_node.ParentNode.Attributes.GetNamedItem("description") Is Nothing Then Description = m_node.ParentNode.Attributes.GetNamedItem("description").Value
            If Not m_node.ParentNode.Attributes.GetNamedItem("host") Is Nothing Then Host = m_node.ParentNode.Attributes.GetNamedItem("host").Value
            If Not m_node.ParentNode.Attributes.GetNamedItem("unit") Is Nothing Then unit = m_node.ParentNode.Attributes.GetNamedItem("unit").Value
            If Not m_node.ParentNode.Attributes.GetNamedItem("device_dll") Is Nothing Then Device = m_node.ParentNode.Attributes.GetNamedItem("device_dll").Value
            If Not m_node.ParentNode.Attributes.GetNamedItem("link_dll") Is Nothing Then Link = m_node.ParentNode.Attributes.GetNamedItem("link.dll").Value
 
            Report_Screen.Rows.Add(New String() {Name, Devices_Search_Value_1.Text, Description, Host, unit, Device, Link})
        Next
 
        ' Set Grid
        Devices_Report_Grid.DataSource = Report_Screen
        Devices_Report_Grid.Columns("Name").Width = 350
        Devices_Report_Grid.Columns("Match Criteria").Width = 300
        Devices_Report_Grid.Columns("Discription").Width = 50
        Devices_Report_Grid.Columns("Device DLL").Width = 150
        Devices_Report_Grid.Columns("Link DLL").Width = 60
        Devices_Report_Grid.Columns("Host").Width = 140
        Devices_Report_Grid.Columns("Unit").Width = 200
[+][-]08.18.2008 at 06:36AM PDT, ID: 22251670

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.18.2008 at 07:11AM PDT, ID: 22251961

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.18.2008 at 07:35AM PDT, ID: 22252222

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: .NET, Microsoft Visual Basic.Net, .Net Editors & IDEs
Tags: VB.NET
Sign Up Now!
Solution Provided By: Snarf0001
Participating Experts: 1
Solution Grade: A
 
 
[+][-]08.18.2008 at 07:42AM PDT, ID: 22252300

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.18.2008 at 07:51AM PDT, ID: 22252396

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.18.2008 at 07:55AM PDT, ID: 22252442

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.18.2008 at 08:00AM PDT, ID: 22252498

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628