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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:00:26+00:00 2026-06-11T05:00:26+00:00

I have this xml: <?xml version=1.0 encoding=utf-8 ?> <Interfaces> <Interface> <Name>Account Lookup</Name> <PossibleResponses> <Response>Account

  • 0

I have this xml:

<?xml version="1.0" encoding="utf-8" ?>
<Interfaces>
  <Interface>
    <Name>Account Lookup</Name>
    <PossibleResponses>
      <Response>Account OK to process</Response>
      <Response>Overridable restriction</Response>
    </PossibleResponses>
  </Interface>
  <Interface>
    <Name>Balance Inquiry</Name>
    <PossibleResponses>
      <Response>Funds available</Response>
      <Response>No funds</Response>
    </PossibleResponses>
  </Interface>
</Interfaces>

I need to retrieve the possible responses for an interface:

// Object was loaded with XML beforehand    
public class Interfaces : XElement {
    public List<string> GetActionsForInterface(string interfaceName) {
        List<string> actionList = new List<string>();
        var actions = from i in this.Elements("Interface")
                      where i.Element("Name").Value == interfaceName
                      select i.Element("PossibleResponses").Element("Response").Value;

        foreach (var action in actions)
            actionList.Add(action);

        return actionList;
    }
}

The result should be a list such as this (for interface ‘Account Lookup’):
Account OK to process
Overridable restriction

But its only returning the first value – ‘Account OK to process’. What is wrong here?

Edit:
I changed my method:

public List<string> GetActionsForInterface(string interfaceName) {
    List<string> actionList = new List<string>();
    var actions = from i in this.Elements("interface")
                  where i.Element("name").Value == interfaceName
                  select i.Element("possibleresponses").Elements("response").Select(X => X.Value);

    foreach (var action in actions)
        actionList.Add(action);

    return actionList;
}

But now I get 2 errors on line ‘actionList.Add(action);’:

The best overloaded method match for System.Collections.Generic.List<string>.Add(string)' has some invalid arguments 
Argument 1: cannot convert from 'System.Collections.Generic.IEnumerable<char>' to 'string'

I suppose the select many is casting the results into something else then strings?

Edit:
To fix the last error:

    foreach (var actions in query)
        foreach(string action in actions)
            actionList.Add(action);

Apparently there is an array within an array here.

  • 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-11T05:00:28+00:00Added an answer on June 11, 2026 at 5:00 am

    This

    select i.Element("PossibleResponses").Element("Response")
    

    returns the first “response” element. Use Elements instead.

    You then need to select many to get the values.

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

Sidebar

Related Questions

I have an getting an xml response on this format <?xml version=\1.0\ encoding=\utf-8\?>\r\n <PlatformResponse
I have this XML at http://localhost/file.xml : <?xml version=1.0 encoding=utf-8?> <val:Root xmlns:val=http://www.hw-group.com/XMLSchema/ste/values.xsd> <Agent> <Version>2.0.3</Version>
I have this XML : <?xml version=1.0 encoding=utf-8 ?> <IMPORT mode=FULL> .... </IMPORT> I'm
I have this XML: <?xml version=1.0 encoding=utf-8?> <ConfiguraCanale ID_Comando=1> <canaleDigitalOUTPUT ID_Canale=1 > <stato>0</stato> </canaleDigitalOUTPUT>
I have this xml file <?xml version=1.0 encoding=UTF-8?> <bo:C837ClaimParent xsi:type=bo:C837ClaimParent xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xmlns:bo=http://somelongpathHere/process/bo> <claimAux> ...
I have this persistence unit: <?xml version=1.0 encoding=UTF-8?> <persistence version=1.0 xmlns=http://java.sun.com/xml/ns/persistence xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:schemaLocation=http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd>
I have the next element <statement id =5> insert into TBTEMPLATES(CTDB_LAST_UPDATOR) values('<?xml version=1.0 encoding=UTF-8?><Interface
xml version 1.0 encoding utf-8 in php, I have tried : echo '<?xml version=1.0
Currently, I have this version of the autocomplete control working when returning XML from
I have this xml <products> <product> <name>Demo</name> </product> <product> <name>Black Beauty III</name> <description>Beautiful les

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.