Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8726641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:17:24+00:00 2026-06-13T08:17:24+00:00

I have this code. Also here is a sample of the XML. I apologize

  • 0

I have this code. Also here is a sample of the XML. I apologize for any confusion

<object type="node" >
    <property name="id" value="1" />
    <property name="name" value="ossvc06_node1" />
      <property name="port_id" value="50050768014062AC" />
      <property name="port_status" value="active" />
      <property name="port_speed" value="4Gb" />
  <property name="port_id" value="50050768013062AC" />
  <property name="port_status" value="active" />
  <property name="port_speed" value="4Gb" />
  <property name="port_id" value="50050768011062AC" />
 <property name="port_status" value="active" />
 <property name="port_speed" value="4Gb" />
 <property name="port_id" value="50050768012062AC" />
 <property name="port_status" value="active" />
 <property name="port_speed" value="4Gb" />
 <property name="hardware" value="8G4" />
 <property name="iscsi_name" value="iqn.1986-03.com.ibm:2145.ossvc06.ossvc06node1" />
 <property name="iscsi_alias" value="" />
 <property name="failover_active" value="no" />
 <property name="failover_name" value="ossvc06_node2" />
 <property name="failover_iscsi_name" value="iqn.1986-       .com.ibm:2145.ossvc06.ossvc06node2" />
 <property name="failover_iscsi_alias" value="" />
 <property name="front_panel_id" value="115286" />
</object>

In the input file there are two of these objects of type “Node” each with different values for the property tags.

In this code I am looking for all the objects of type “node” in the incoming XML. There are 2 of them. The ‘var nodes’ statement evaluates correctly. In the debugger I can see two XElements with what appears to be the proper type and elements in the element list. However, the statement that gets the elements and assigns them to a list has ChildElements from both of the objects of type “node” that are in the XML and I am not sure why.

//load the input file
 XDocument xdoc = XDocument.Load(_InputFile);

//get the object of type 'node'

//this code gives the results expected
// in the debugger each XElement appears to have the proper value and childElements
var nodes = from node in xdoc.Descendants("object")
                        where node.Attribute("type").Value == "node"
                        select node;

foreach (XElement nodelement  in nodes)
{  

    // problem happens here, the child elements from both  nodes get assigned to the list 
    List<XElement> nodeles = nodelement.Elements().ToList();
    Node node = NodeFactory(nodelement);

    // now assign the node to the correct IO group
    var iogrp = SVCClusters[0].IOGroups.Where(io => io.Name == node.IOGroupName);
    if (iogrp.FirstOrDefault().FirstNode == null) { iogrp.FirstOrDefault().FirstNode = node; }
    else { iogrp.FirstOrDefault().SecondNode = node; }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T08:17:25+00:00Added an answer on June 13, 2026 at 8:17 am

    Can you run this in a console app and tell me what you get

        static void Main(string[] args)
        {
            XDocument xdoc = XDocument.Parse("<root><object type=\"node\" ><property name=\"id\" value=\"1\" /><property name=\"name\" value=\"ossvc06_node1\" /></object><object type=\"node\" ><property name=\"id\" value=\"2\" /><property name=\"name\" value=\"ossvc06_node2\" /></object></root>");
    
            var nodes = xdoc.Descendants("object").Where(node => node.Attribute("type").Value == "node").ToList();
    
            foreach (XElement nodelement in nodes)
            {
                List<XElement> nodeles = nodelement.Elements().ToList();
    
                foreach (var node in nodeles)
                    Console.WriteLine(node);
            }
        }
    

    You should have 4 rows output to the console

    Edit—

    Original issue was that an XPath expression “//property[@name=’port_id’]” was being used. This queries from the document root, not from the current node.

    Change the XPath to be either “property[@name=’port_id’] or “.//property[@name=’port_id’]”

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code Math.min(someVariable, 500)) I also have some divs which I have
I have some code that looks like this. There is also an autoincrement field
I have this code in XAML <Grid x:Name=LayoutRoot Background=Transparent> <Grid.RowDefinitions> <RowDefinition Height=Auto/> <RowDefinition Height=*/>
C# code. I have populated checkboxes, but not radiobuttons before. Here is a sample
I have this code <div id=main style=background:#aaaaaa;float:left;height:160px;margin:5px;position:relative;display:block;width:630px;> <div id=1 class=item style=background:#ffaacc;float:left;width:200px;height:150px;margin:5px;position:absolute;left:0px;top:0px;> </div> <div id=2
I have this code : void Main() { System.Timers.Timer t = new System.Timers.Timer (1000);
I have this code for changing the image of a button: - (void)mouseEntered:(NSEvent *)event
I have this code: EditText value = ( EditText )findViewById( R.id.editbox ); Integer int_value
I have this code: ie1.link(:text, /Exception:/) It is producing an error message which I
I have this code: def __init__(self, a, b, c, d...): self.a = a self.b

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.