How can I get data from an ArrayOffXElement RRS feed

  • Question

  • Hi, I'm calling a web service in Azure Function, which returns me an ArrayOfXElement type, but I don't know how to get to the data

    Thursday, November 21, 2019 1:00 PM

All replies

  • Hello,

    Use for for each where the iterator should be an XElement.

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    profile for Karen Payne on Stack Exchange

    Thursday, November 21, 2019 2:12 PM
  • Hi alramirez7705,

    Thank you for posting here.

    For your question, you want to get data from a ArrayOfXelement.

    This is an example of ArrayOfXelement.

    <DataSet xmlns="">
      <xs:schema xmlns="" xmlns:xs="" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="NewDataSet">
        <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
            <xs:choice minOccurs="0" maxOccurs="unbounded">
              <xs:element name="Table">
                    <xs:element name="ID" type="xs:int" minOccurs="0"/>
                    <xs:element name="classtitle" type="xs:string" minOccurs="0"/>
                    <xs:element name="classfile" type="xs:string" minOccurs="0"/>
                    <xs:element name="userName" type="xs:string" minOccurs="0"/>
                    <xs:element name="note" type="xs:string" minOccurs="0"/>
      <diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
        <NewDataSet xmlns="">
          <Table diffgr:id="Table1" msdata:rowOrder="0">
          <Table diffgr:id="Table2" msdata:rowOrder="1">
          <Table diffgr:id="Table3" msdata:rowOrder="2">
          <Table diffgr:id="Table4" msdata:rowOrder="3">
          <Table diffgr:id="Table5" msdata:rowOrder="4">

    For such a format, you can use Nodes.Descendants("Table") to get the label you want and then get the data through foreach.

    The following is a sample code.

                private async void FindAll()
                    mywebservice.kechengbiaoSoapClient client = new mywebservice.kechengbiaoSoapClient();
                    ArrayOfXElement tables = await client.loadallclassAsync();
                    foreach (XElement el in tables.Nodes.Descendants("Table"))
                        ClassIndex table = new ClassIndex();
                        foreach (XElement ell in el.Nodes())
                            //  table.IndexId = Convert.ToInt32(ell.Value);                   
                            switch (Convert.ToString(ell.Name))
                                case "ID":
                                    table.IndexId = Convert.ToInt32(ell.Value);
                                case "classtitle":
                                    table.IndexTitle = ell.Value;
                    listView.DataContext = data;

    Hope this could be helpful.

    Best Regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Friday, November 22, 2019 2:13 AM