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 4107550
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T21:31:48+00:00 2026-05-20T21:31:48+00:00

I have XML file with the following structure: <rule ID=16 Attribute=Savvy Parametr=> <body> <term

  • 0

I have XML file with the following structure:

<rule ID="16" Attribute="Savvy" Parametr="">
      <body>
        <term Operation="AND">
          <IF_ID>8</IF_ID>
          <Ratio>=</Ratio>
          <IF_Value>impossible</IF_Value>
        </term>
        <term Operation="OR">
          <IF_ID>9</IF_ID>
          <Ratio>=</Ratio>
          <IF_Value>yes</IF_Value>
        </term>
        <term Operation="AND">
          <IF_ID>8</IF_ID>
          <Ratio>!=</Ratio>
          <IF_Value>impossible</IF_Value>
        </term>
        <term>
          <IF_ID>9</IF_ID>
          <Ratio>=</Ratio>
          <IF_Value>no</IF_Value>
        </term>
      </body>
      <value>normal savvy</value>
    </rule>

I need to add it to Listbox and get 1 row:

8 = impossible AND 9 = yes OR 8 != impossible AND 9 = no - normal savvy
  • 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-05-20T21:31:48+00:00Added an answer on May 20, 2026 at 9:31 pm

    If you need to know how to read an attribute via XDocument it is as simple as doing xElement.Attribute("Operation")

    Now to actually get the string structure you want it all you need to do is loop through your terms and append them to a string.

    var xDocument = XDocument.Parse(x);
    var stringBuilder = new StringBuilder();
    foreach (var xElement in xDocument.Descendants("term"))
    {
        var operationValue = xElement.Attribute("Operation") == null ? string.Empty : xElement.Attribute("Operation").Value;
        stringBuilder.AppendFormat("{0} {1} {2} {3} ", 
                                        xElement.Element("IF_ID").Value, 
                                        xElement.Element("Ratio").Value,
                                        xElement.Element("IF_Value").Value,
                                        operationValue);
    }
    stringBuilder.AppendFormat("- {0}", xDocument.Descendants("value").First().Value);
    

    This assumes that you will have a value for each element and there is only one <rule/>. Null checks would be needed to make it correct for each element.

    8 = impossible AND 9 = yes OR 8 !=
    impossible AND 9 = no – normal savvy

    Now how this relates to a listbox I am not sure and might require a bit more detail?

    var item = new ListItem(stringBuilder.ToString());
    listBox.Items.Add(item);
    

    ???

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

Sidebar

Related Questions

I have a large xml file (approx. 10 MB) in following simple structure: <Errors>
If i have the following directory structure: Project1/bin/debug Project2/xml/file.xml I am trying to refer
I have an XML file in the following structure. <NewDataSet> <markers> <name>name text</name> <desc>desc
I have an XML file with the following structure: <Products> <Product name=MyProduct1> <Components> <Component
The XML file have the following structure <RootElement> <TestElement Count=10/> </RootElement> I need to
I have the following file structure (XML files 'index.xml' in nested folders): index.xml foo/index.xml
I have a sample htm file with following structure and it POSTs the xml
I have xml file whose structure is defined with following xsd: <?xml version=1.0 encoding=utf-8?>
I have an XML file similar in structure to the following: <Parent> <Child>5</Child> <Child>3</Child>
ich have a xml file with the following structure: <layer1 name=this is layer1> <messages>

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.