Click here to Skip to main content
15,889,266 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I have a XML coming from WCF service i have to show top 10 records of searchResultsRecord from it but i am unable to loop through it as the Xpath is wrong.

HTML
-<Payload xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">


-<request xmlns="http://abr.business.gov.au/ABRXMLSearch/">


-<nameSearchRequest>

<authenticationGUID>88bf33e2-96a6-402c-a870-47c03af2a80b</authenticationGUID>

<name>ANZ</name>


-<filters>


-<nameType>

<tradingName>N</tradingName>

<legalName>N</legalName>

</nameType>

<postcode/>


-<stateCode>

<QLD>N</QLD>

<NT>N</NT>

<SA>N</SA>

<WA>N</WA>

<VIC>N</VIC>

<ACT>N</ACT>

<TAS>N</TAS>

<NSW>N</NSW>

</stateCode>

</filters>

</nameSearchRequest>

</request>


-<response xmlns="http://abr.business.gov.au/ABRXMLSearch/">

<usageStatement>The Registrar of the ABR monitors the quality of the information available on this website and updates the information regularly. However, neither the Registrar of the ABR nor the Commonwealth guarantee that the information available through this service (including search results) is accurate, up to date, complete or accept any liability arising from the use of or reliance upon this site.</usageStatement>

<dateRegisterLastUpdated>2019-10-23</dateRegisterLastUpdated>

<dateTimeRetrieved>2019-10-23T12:48:10.9298689+05:30</dateTimeRetrieved>


-<searchResultsList>

<numberOfRecords>201</numberOfRecords>

<exceedsMaximum>N</exceedsMaximum>


-<searchResultsRecord>


-<ABN>

<identifierValue>11005357522</identifierValue>

<identifierStatus>Active</identifierStatus>

</ABN>


-<businessName>

<organisationName>ANZ</organisationName>

<score>100</score>

<isCurrentIndicator>Y</isCurrentIndicator>

</businessName>


-<mainBusinessPhysicalAddress>

<stateCode>VIC</stateCode>

<postcode>3008</postcode>

<isCurrentIndicator>Y</isCurrentIndicator>

</mainBusinessPhysicalAddress>

</searchResultsRecord>


-<searchResultsRecord>


-<ABN>

<identifierValue>30146899103</identifierValue>

<identifierStatus>Cancelled</identifierStatus>

</ABN>


-<mainName>

<organisationName>ANZ COMPANIES PTY LIMITED</organisationName>

<score>100</score>

<isCurrentIndicator>Y</isCurrentIndicator>

</mainName>


-<mainBusinessPhysicalAddress>

<stateCode>NSW</stateCode>

<postcode>2134</postcode>

<isCurrentIndicator>Y</isCurrentIndicator>

</mainBusinessPhysicalAddress>

</searchResultsRecord>


-<searchResultsRecord>


-<ABN>

<identifierValue>22169448220</identifierValue>

<identifierStatus>Active</identifierStatus>

</ABN>


-<mainName>

<organisationName>ANZ CORPORATION PTY LTD</organisationName>

<score>100</score>

<isCurrentIndicator>Y</isCurrentIndicator>

</mainName>


-<mainBusinessPhysicalAddress>

<stateCode>NSW</stateCode>

<postcode>2009</postcode>

<isCurrentIndicator>Y</isCurrentIndicator>

</mainBusinessPhysicalAddress>

</searchResultsRecord>


-<searchResultsRecord>


-<ABN>

<identifierValue>32601478849</identifierValue>

<identifierStatus>Active</identifierStatus>

</ABN>


-<businessName>

<organisationName>AUS AND NZ</organisationName>

<score>100</score>

<isCurrentIndicator>Y</isCurrentIndicator>

</businessName>


-<mainBusinessPhysicalAddress>

<stateCode>NSW</stateCode>

<postcode>2135</postcode>

<isCurrentIndicator>Y</isCurrentIndicator>

</mainBusinessPhysicalAddress>

</searchResultsRecord>


-<searchResultsRecord>


-<ABN>

<identifierValue>62143244035</identifierValue>

<identifierStatus>Cancelled</identifierStatus>

</ABN>


-<mainName>

<organisationName>AUS-NZ Pty Ltd</organisationName>

<score>100</score>

<isCurrentIndicator>Y</isCurrentIndicator>

</mainName>


-<mainBusinessPhysicalAddress>

<stateCode>QLD</stateCode>

<postcode>4818</postcode>

<isCurrentIndicator>Y</isCurrentIndicator>

</mainBusinessPhysicalAddress>

</searchResultsRecord>


-<searchResultsRecord>


-<ABN>

<identifierValue>58620076075</identifierValue>

<identifierStatus>Active</identifierStatus>

</ABN>


-<mainName>

<organisationName>AAIH ANZ PTY LTD</organisationName>

<score>97</score>

<isCurrentIndicator>Y</isCurrentIndicator>

</mainName>


-<mainBusinessPhysicalAddress>

<stateCode>QLD</stateCode>

<postcode>4006</postcode>

<isCurrentIndicator>Y</isCurrentIndicator>

</mainBusinessPhysicalAddress>

</searchResultsRecord>


-<searchResultsRecord>


-<ABN>

<identifierValue>71884645219</identifierValue>

<identifierStatus>Active</identifierStatus>

</ABN>


-<legalName>

<fullName>ABAS ANZ</fullName>

<score>97</score>

<isCurrentIndicator>N</isCurrentIndicator>

</legalName>


-<mainBusinessPhysicalAddress>

<stateCode>NSW</stateCode>

<postcode>2197</postcode>

<isCurrentIndicator>Y</isCurrentIndicator>

</mainBusinessPhysicalAddress>

</searchResultsRecord>


-<searchResultsRecord>


-<ABN>

<identifierValue>30124078119</identifierValue>

<identifierStatus>Cancelled</identifierStatus>

</ABN>


-<mainName>

<organisationName>ABC (AUST & NZ) PTY LTD</organisationName>

<score>97</score>

<isCurrentIndicator>Y</isCurrentIndicator>

</mainName>


-<mainBusinessPhysicalAddress>

<stateCode>VIC</stateCode>

<postcode>3181</postcode>

<isCurrentIndicator>Y</isCurrentIndicator>

</mainBusinessPhysicalAddress>

</searchResultsRecord>


-<searchResultsRecord>


-<ABN>

<identifierValue>53863463962</identifierValue>

<identifierStatus>Cancelled</identifierStatus>

</ABN>


-<businessName>

<organisationName>ABIM ANZ</organisationName>

<score>97</score>

<isCurrentIndicator>N</isCurrentIndicator>

</businessName>


-<mainBusinessPhysicalAddress>

<stateCode>VIC</stateCode>

<postcode>3066</postcode>

<isCurrentIndicator>Y</isCurrentIndicator>

</mainBusinessPhysicalAddress>

</searchResultsRecord>


-<searchResultsRecord>


-<ABN>

<identifierValue>82133580015</identifierValue>

<identifierStatus>Active</identifierStatus>

</ABN>


-<mainName>

<organisationName>ACCA Australia & New Zealand Ltd</organisationName>

<score>97</score>

<isCurrentIndicator>Y</isCurrentIndicator>

</mainName>


-<mainBusinessPhysicalAddress>

<stateCode>NSW</stateCode>

<postcode>2000</postcode>

<isCurrentIndicator>Y</isCurrentIndicator>

</mainBusinessPhysicalAddress>

</searchResultsRecord>


-<searchResultsRecord>


-<ABN>

<identifierValue>84612765143</identifierValue>

<identifierStatus>Active</identifierStatus>

</ABN>


-<mainName>

<organisationName>ACCELEDENT AUSTRALIA NZ PTY LTD</organisationName>

<score>97</score>

<isCurrentIndicator>Y</isCurrentIndicator>

</mainName>


-<mainBusinessPhysicalAddress>

<stateCode>QLD</stateCode>

<postcode>4165</postcode>

<isCurrentIndicator>Y</isCurrentIndicator>

</mainBusinessPhysicalAddress>

</searchResultsRecord>


-<searchResultsRecord>


-<ABN>

<identifierValue>89000563002</identifierValue>

<identifierStatus>Cancelled</identifierStatus>

</ABN>


-<mainTradingName>

<organisationName>ACHESON ANZ PTY LTD</organisationName>

<score>97</score>

<isCurrentIndicator>Y</isCurrentIndicator>

</mainTradingName>


-<mainBusinessPhysicalAddress>

<stateCode>NSW</stateCode>

<postcode>2170</postcode>

<isCurrentIndicator>Y</isCurrentIndicator>

</mainBusinessPhysicalAddress>

</searchResultsRecord>

-<ABN>

<identifierValue>51621646277</identifierValue>

<identifierStatus>Active</identifierStatus>

</ABN>


-<mainName>

<organisationName>AIRLINES FOR AUSTRALIA AND NEW ZEALAND LTD</organisationName>

<score>97</score>

<isCurrentIndicator>Y</isCurrentIndicator>

</mainName>


-<mainBusinessPhysicalAddress>

<stateCode>NSW</stateCode>

<postcode>2020</postcode>

<isCurrentIndicator>Y</isCurrentIndicator>

</mainBusinessPhysicalAddress>

</searchResultsRecord>


What I have tried:

C#
foreach (XElement xe in doc.Descendants("searchResultsRecord").Take(50))
           {
               XmlDocument doc1 = new XmlDocument();

               xe.Add(doc1);
           }


OR

C#
foreach (XmlNode result in responseXml.SelectNodes("//Payload/searchResultsList/searchResultsRecord"))
          {
              XmlDocument doc1 = new XmlDocument();
              result.AppendChild(doc1);
          }
Posted
Updated 25-Oct-19 19:58pm

First make sure your XML is valid and does not contain & characters etc.
<Payload xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

  -<request xmlns="http://abr.business.gov.au/ABRXMLSearch/">

    -<nameSearchRequest>

      <authenticationGUID>88bf33e2-96a6-402c-a870-47c03af2a80b</authenticationGUID>
      <name>ANZ</name>


      -<filters>

        -<nameType>
          <tradingName>N</tradingName>
          <legalName>N</legalName>
        </nameType>

        <postcode/>

        -<stateCode>

          <QLD>N</QLD>

          <NT>N</NT>

          <SA>N</SA>

          <WA>N</WA>

          <VIC>N</VIC>

          <ACT>N</ACT>

          <TAS>N</TAS>

          <NSW>N</NSW>

        </stateCode>

      </filters>

    </nameSearchRequest>

  </request>


  -<response xmlns="http://abr.business.gov.au/ABRXMLSearch/">

    <usageStatement>The Registrar of the ABR monitors the quality of the information available on this website and updates the information regularly. However, neither the Registrar of the ABR nor the Commonwealth guarantee that the information available through this service (including search results) is accurate, up to date, complete or accept any liability arising from the use of or reliance upon this site.</usageStatement>

    <dateRegisterLastUpdated>2019-10-23</dateRegisterLastUpdated>

    <dateTimeRetrieved>2019-10-23T12:48:10.9298689+05:30</dateTimeRetrieved>


    -<searchResultsList>

      <numberOfRecords>201</numberOfRecords>

      <exceedsMaximum>N</exceedsMaximum>


      -<searchResultsRecord>


        -<ABN>

          <identifierValue>11005357522</identifierValue>

          <identifierStatus>Active</identifierStatus>

        </ABN>


        -<businessName>

          <organisationName>ANZ</organisationName>

          <score>100</score>

          <isCurrentIndicator>Y</isCurrentIndicator>

        </businessName>


        -<mainBusinessPhysicalAddress>

          <stateCode>VIC</stateCode>

          <postcode>3008</postcode>

          <isCurrentIndicator>Y</isCurrentIndicator>

        </mainBusinessPhysicalAddress>

      </searchResultsRecord>


      -<searchResultsRecord>


        -<ABN>

          <identifierValue>30146899103</identifierValue>

          <identifierStatus>Cancelled</identifierStatus>

        </ABN>


        -<mainName>

          <organisationName>ANZ COMPANIES PTY LIMITED</organisationName>

          <score>100</score>

          <isCurrentIndicator>Y</isCurrentIndicator>

        </mainName>


        -<mainBusinessPhysicalAddress>

          <stateCode>NSW</stateCode>

          <postcode>2134</postcode>

          <isCurrentIndicator>Y</isCurrentIndicator>

        </mainBusinessPhysicalAddress>

      </searchResultsRecord>


      -<searchResultsRecord>


        -<ABN>

          <identifierValue>22169448220</identifierValue>

          <identifierStatus>Active</identifierStatus>

        </ABN>


        -<mainName>

          <organisationName>ANZ CORPORATION PTY LTD</organisationName>

          <score>100</score>

          <isCurrentIndicator>Y</isCurrentIndicator>

        </mainName>


        -<mainBusinessPhysicalAddress>

          <stateCode>NSW</stateCode>

          <postcode>2009</postcode>

          <isCurrentIndicator>Y</isCurrentIndicator>

        </mainBusinessPhysicalAddress>

      </searchResultsRecord>


      -<searchResultsRecord>


        -<ABN>

          <identifierValue>32601478849</identifierValue>

          <identifierStatus>Active</identifierStatus>

        </ABN>


        -<businessName>

          <organisationName>AUS AND NZ</organisationName>

          <score>100</score>

          <isCurrentIndicator>Y</isCurrentIndicator>

        </businessName>


        -<mainBusinessPhysicalAddress>

          <stateCode>NSW</stateCode>

          <postcode>2135</postcode>

          <isCurrentIndicator>Y</isCurrentIndicator>

        </mainBusinessPhysicalAddress>

      </searchResultsRecord>


      -<searchResultsRecord>


        -<ABN>

          <identifierValue>62143244035</identifierValue>

          <identifierStatus>Cancelled</identifierStatus>

        </ABN>


        -<mainName>

          <organisationName>AUS-NZ Pty Ltd</organisationName>

          <score>100</score>

          <isCurrentIndicator>Y</isCurrentIndicator>

        </mainName>


        -<mainBusinessPhysicalAddress>

          <stateCode>QLD</stateCode>

          <postcode>4818</postcode>

          <isCurrentIndicator>Y</isCurrentIndicator>

        </mainBusinessPhysicalAddress>

      </searchResultsRecord>


      -<searchResultsRecord>


        -<ABN>

          <identifierValue>58620076075</identifierValue>

          <identifierStatus>Active</identifierStatus>

        </ABN>


        -<mainName>

          <organisationName>AAIH ANZ PTY LTD</organisationName>

          <score>97</score>

          <isCurrentIndicator>Y</isCurrentIndicator>

        </mainName>


        -<mainBusinessPhysicalAddress>

          <stateCode>QLD</stateCode>

          <postcode>4006</postcode>

          <isCurrentIndicator>Y</isCurrentIndicator>

        </mainBusinessPhysicalAddress>

      </searchResultsRecord>


      -<searchResultsRecord>


        -<ABN>

          <identifierValue>71884645219</identifierValue>

          <identifierStatus>Active</identifierStatus>

        </ABN>


        -<legalName>

          <fullName>ABAS ANZ</fullName>

          <score>97</score>

          <isCurrentIndicator>N</isCurrentIndicator>

        </legalName>


        -<mainBusinessPhysicalAddress>

          <stateCode>NSW</stateCode>

          <postcode>2197</postcode>

          <isCurrentIndicator>Y</isCurrentIndicator>

        </mainBusinessPhysicalAddress>

      </searchResultsRecord>


      -<searchResultsRecord>


        -<ABN>

          <identifierValue>30124078119</identifierValue>

          <identifierStatus>Cancelled</identifierStatus>

        </ABN>


        -<mainName>

          <organisationName>ABC (AUST and NZ) PTY LTD</organisationName>

          <score>97</score>

          <isCurrentIndicator>Y</isCurrentIndicator>

        </mainName>


        -<mainBusinessPhysicalAddress>

          <stateCode>VIC</stateCode>

          <postcode>3181</postcode>

          <isCurrentIndicator>Y</isCurrentIndicator>

        </mainBusinessPhysicalAddress>

      </searchResultsRecord>


      -<searchResultsRecord>


        -<ABN>

          <identifierValue>53863463962</identifierValue>

          <identifierStatus>Cancelled</identifierStatus>

        </ABN>


        -<businessName>

          <organisationName>ABIM ANZ</organisationName>

          <score>97</score>

          <isCurrentIndicator>N</isCurrentIndicator>

        </businessName>


        -<mainBusinessPhysicalAddress>

          <stateCode>VIC</stateCode>

          <postcode>3066</postcode>

          <isCurrentIndicator>Y</isCurrentIndicator>

        </mainBusinessPhysicalAddress>

      </searchResultsRecord>


      -<searchResultsRecord>


        -<ABN>

          <identifierValue>82133580015</identifierValue>

          <identifierStatus>Active</identifierStatus>

        </ABN>


        -<mainName>

          <organisationName>ACCA Australia and New Zealand Ltd</organisationName>

          <score>97</score>

          <isCurrentIndicator>Y</isCurrentIndicator>

        </mainName>


        -<mainBusinessPhysicalAddress>

          <stateCode>NSW</stateCode>

          <postcode>2000</postcode>

          <isCurrentIndicator>Y</isCurrentIndicator>

        </mainBusinessPhysicalAddress>

      </searchResultsRecord>


      -<searchResultsRecord>


        -<ABN>

          <identifierValue>84612765143</identifierValue>

          <identifierStatus>Active</identifierStatus>

        </ABN>


        -<mainName>

          <organisationName>ACCELEDENT AUSTRALIA NZ PTY LTD</organisationName>

          <score>97</score>

          <isCurrentIndicator>Y</isCurrentIndicator>

        </mainName>


        -<mainBusinessPhysicalAddress>

          <stateCode>QLD</stateCode>

          <postcode>4165</postcode>

          <isCurrentIndicator>Y</isCurrentIndicator>

        </mainBusinessPhysicalAddress>

      </searchResultsRecord>


      -<searchResultsRecord>


        -<ABN>

          <identifierValue>89000563002</identifierValue>

          <identifierStatus>Cancelled</identifierStatus>

        </ABN>


        -<mainTradingName>

          <organisationName>ACHESON ANZ PTY LTD</organisationName>

          <score>97</score>

          <isCurrentIndicator>Y</isCurrentIndicator>

        </mainTradingName>


        -<mainBusinessPhysicalAddress>

          <stateCode>NSW</stateCode>

          <postcode>2170</postcode>

          <isCurrentIndicator>Y</isCurrentIndicator>

        </mainBusinessPhysicalAddress>

      </searchResultsRecord>

      -<searchResultsRecord>

        -<ABN>

        <identifierValue>51621646277</identifierValue>

        <identifierStatus>Active</identifierStatus>

      </ABN>


      -<mainName>

        <organisationName>AIRLINES FOR AUSTRALIA AND NEW ZEALAND LTD</organisationName>

        <score>97</score>

        <isCurrentIndicator>Y</isCurrentIndicator>

      </mainName>


      -<mainBusinessPhysicalAddress>

        <stateCode>NSW</stateCode>

        <postcode>2020</postcode>

        <isCurrentIndicator>Y</isCurrentIndicator>

      </mainBusinessPhysicalAddress>

      </searchResultsRecord>
      
   </searchResultsList>
      
 </response>
 </Payload>

Then use this code:
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.Windows.Forms;
using System.Xml;
using System.Xml.Linq;

        private void Test4(string fileName)
        {
            // Response
            XElement _x = XElement.Load(fileName).Elements().Last<XElement>();
            XElement items = _x.Elements().Last<XElement>();

            // searchResultsList
            List<string> resultList = new List<string>();

            foreach (var item in items.Elements())
            {
                if (item.Name.LocalName == "searchResultsRecord")
                {
                    string temp = string.Empty;

                    foreach (var subItem in item.Elements())
                    {
                        foreach (var subItem2 in subItem.Elements())
                        {
                            temp += subItem2.Name.LocalName + " " + subItem2.Value + " ";
                        }
                    }

                    resultList.Add(temp);
                }
            }

            Debug.Print("Count = " + resultList.Count());

            foreach (var item in resultList)
            {
                Debug.Print(item);
            }
        }
 
Share this answer
 
v3
Comments
srko 24-Oct-19 4:04am    
Please format it in proper XML, it's look messy. And also provide some better description for correction.
OriginalGriff 24-Oct-19 4:41am    
Downvote countered
RickZeeland 24-Oct-19 4:44am    
Finally some justice after all :)
srko 24-Oct-19 6:22am    
hahahahah mutual help
OriginalGriff 24-Oct-19 6:36am    
No, some idiot downvoted a good answer, so I corrected it.
If you prefer to work with classes you can make use of this online XML converter:
Xml2CSharp.com | Convert your XML Examples into XmlSerializer compatable C# Classes[^]

It will generate:
/* 
Licensed under the Apache License, Version 2.0
    
http://www.apache.org/licenses/LICENSE-2.0
*/
using System;
using System.Xml.Serialization;
using System.Collections.Generic;

namespace Xml2CSharp
{
	[XmlRoot(ElementName="nameType", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
	public class NameType {
		[XmlElement(ElementName="tradingName", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
		public string TradingName { get; set; }
		[XmlElement(ElementName="legalName", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
		public string LegalName { get; set; }
	}

	[XmlRoot(ElementName="stateCode", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
	public class StateCode {
		[XmlElement(ElementName="QLD", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
		public string QLD { get; set; }
		[XmlElement(ElementName="NT", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
		public string NT { get; set; }
		[XmlElement(ElementName="SA", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
		public string SA { get; set; }
		[XmlElement(ElementName="WA", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
		public string WA { get; set; }
		[XmlElement(ElementName="VIC", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
		public string VIC { get; set; }
		[XmlElement(ElementName="ACT", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
		public string ACT { get; set; }
		[XmlElement(ElementName="TAS", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
		public string TAS { get; set; }
		[XmlElement(ElementName="NSW", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
		public string NSW { get; set; }
	}

	[XmlRoot(ElementName="filters", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
	public class Filters {
		[XmlElement(ElementName="nameType", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
		public NameType NameType { get; set; }
		[XmlElement(ElementName="postcode", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
		public string Postcode { get; set; }
		[XmlElement(ElementName="stateCode", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
		public StateCode StateCode { get; set; }
	}

	[XmlRoot(ElementName="nameSearchRequest", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
	public class NameSearchRequest {
		[XmlElement(ElementName="authenticationGUID", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
		public string AuthenticationGUID { get; set; }
		[XmlElement(ElementName="name", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
		public string Name { get; set; }
		[XmlElement(ElementName="filters", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
		public Filters Filters { get; set; }
	}

	[XmlRoot(ElementName="request", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
	public class Request {
		[XmlElement(ElementName="nameSearchRequest", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
		public NameSearchRequest NameSearchRequest { get; set; }
		[XmlAttribute(AttributeName="xmlns")]
		public string Xmlns { get; set; }
	}

	[XmlRoot(ElementName="ABN", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
	public class ABN {
		[XmlElement(ElementName="identifierValue", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
		public string IdentifierValue { get; set; }
		[XmlElement(ElementName="identifierStatus", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
		public string IdentifierStatus { get; set; }
	}

	[XmlRoot(ElementName="businessName", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
	public class BusinessName {
		[XmlElement(ElementName="organisationName", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
		public string OrganisationName { get; set; }
		[XmlElement(ElementName="score", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
		public string Score { get; set; }
		[XmlElement(ElementName="isCurrentIndicator", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
		public string IsCurrentIndicator { get; set; }
	}

	[XmlRoot(ElementName="mainBusinessPhysicalAddress", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
	public class MainBusinessPhysicalAddress {
		[XmlElement(ElementName="stateCode", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
		public string StateCode { get; set; }
		[XmlElement(ElementName="postcode", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
		public string Postcode { get; set; }
		[XmlElement(ElementName="isCurrentIndicator", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
		public string IsCurrentIndicator { get; set; }
	}

	[XmlRoot(ElementName="searchResultsRecord", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
	public class SearchResultsRecord {
		[XmlElement(ElementName="ABN", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
		public ABN ABN { get; set; }
		[XmlElement(ElementName="businessName", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
		public BusinessName BusinessName { get; set; }
		[XmlElement(ElementName="mainBusinessPhysicalAddress", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
		public MainBusinessPhysicalAddress MainBusinessPhysicalAddress { get; set; }
		[XmlElement(ElementName="mainName", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
		public MainName MainName { get; set; }
		[XmlElement(ElementName="legalName", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
		public LegalName LegalName { get; set; }
		[XmlElement(ElementName="mainTradingName", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
		public MainTradingName MainTradingName { get; set; }
	}

	[XmlRoot(ElementName="mainName", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
	public class MainName {
		[XmlElement(ElementName="organisationName", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
		public string OrganisationName { get; set; }
		[XmlElement(ElementName="score", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
		public string Score { get; set; }
		[XmlElement(ElementName="isCurrentIndicator", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
		public string IsCurrentIndicator { get; set; }
	}

	[XmlRoot(ElementName="legalName", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
	public class LegalName {
		[XmlElement(ElementName="fullName", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
		public string FullName { get; set; }
		[XmlElement(ElementName="score", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
		public string Score { get; set; }
		[XmlElement(ElementName="isCurrentIndicator", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
		public string IsCurrentIndicator { get; set; }
	}

	[XmlRoot(ElementName="mainTradingName", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
	public class MainTradingName {
		[XmlElement(ElementName="organisationName", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
		public string OrganisationName { get; set; }
		[XmlElement(ElementName="score", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
		public string Score { get; set; }
		[XmlElement(ElementName="isCurrentIndicator", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
		public string IsCurrentIndicator { get; set; }
	}

	[XmlRoot(ElementName="searchResultsList", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
	public class SearchResultsList {
		[XmlElement(ElementName="numberOfRecords", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
		public string NumberOfRecords { get; set; }
		[XmlElement(ElementName="exceedsMaximum", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
		public string ExceedsMaximum { get; set; }
		[XmlElement(ElementName="searchResultsRecord", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
		public List<SearchResultsRecord> SearchResultsRecord { get; set; }
	}

	[XmlRoot(ElementName="response", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
	public class Response {
		[XmlElement(ElementName="usageStatement", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
		public string UsageStatement { get; set; }
		[XmlElement(ElementName="dateRegisterLastUpdated", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
		public string DateRegisterLastUpdated { get; set; }
		[XmlElement(ElementName="dateTimeRetrieved", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
		public string DateTimeRetrieved { get; set; }
		[XmlElement(ElementName="searchResultsList", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
		public SearchResultsList SearchResultsList { get; set; }
		[XmlAttribute(AttributeName="xmlns")]
		public string Xmlns { get; set; }
	}

	[XmlRoot(ElementName="Payload")]
	public class Payload {
		[XmlElement(ElementName="request", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
		public Request Request { get; set; }
		[XmlElement(ElementName="response", Namespace="http://abr.business.gov.au/ABRXMLSearch/")]
		public Response Response { get; set; }
		[XmlAttribute(AttributeName="xsd", Namespace="http://www.w3.org/2000/xmlns/")]
		public string Xsd { get; set; }
		[XmlAttribute(AttributeName="xsi", Namespace="http://www.w3.org/2000/xmlns/")]
		public string Xsi { get; set; }
	}

}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900