Chandra Sekhar

Chandra Sekhar

  • 2k
  • 41
  • 1.7k

Find the Xpath of the xml and loop through the records.

Oct 23 2019 10:48 PM
  1. <server>  
  2. <responses>  
  3. <Session.loginRs status="success" sessionID="A3786008:DB8D4E58:96A1B82A:E606D2BC:7A35D91D:48E90C41" expiredPassword="0" fullName="Express Admin" roleBasedSecurity="1" entityID="1" userID="1" partyID="0" consumerID="0" />  
  4. <IntegrationCBO.ProcessWCFServiceRs status="success">  
  5. <Payload xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">  
  6. <request xmlns="http://abr.business.gov.au/ABRXMLSearch/">  
  7. <nameSearchRequest>  
  8. <authenticationGUID>88bf33e2-96a6-402c-a870-47c03af2a80b</authenticationGUID>  
  9. <name>ANZ</name>  
  10. <filters>  
  11. <nameType>  
  12. <tradingName>Y</tradingName>  
  13. <legalName>Y</legalName>  
  14. </nameType>  
  15. <postcode xsi:nil="true" />  
  16. <stateCode>  
  17. <QLD>Y</QLD>  
  18. <NT>Y</NT>  
  19. <SA>Y</SA>  
  20. <WA>Y</WA>  
  21. <VIC>Y</VIC>  
  22. <ACT>Y</ACT>  
  23. <TAS>Y</TAS>  
  24. <NSW>Y</NSW>  
  25. </stateCode>  
  26. </filters>  
  27. </nameSearchRequest>  
  28. </request>  
  29. <response xmlns="http://abr.business.gov.au/ABRXMLSearch/">  
  30. <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>  
  31. <dateRegisterLastUpdated>2019-10-22</dateRegisterLastUpdated>  
  32. <dateTimeRetrieved>2019-10-22T14:03:33.3141574+05:30</dateTimeRetrieved>  
  33. <searchResultsList>  
  34. <numberOfRecords>201</numberOfRecords>  
  35. <exceedsMaximum>N</exceedsMaximum>  
  36. <searchResultsRecord>  
  37. <ABN>  
  38. <identifierValue>11005357522</identifierValue>  
  39. <identifierStatus>Active</identifierStatus>  
  40. </ABN>  
  41. <businessName>  
  42. <organisationName>ANZ</organisationName>  
  43. <score>100</score>  
  44. <isCurrentIndicator>Y</isCurrentIndicator>  
  45. </businessName>  
  46. <mainBusinessPhysicalAddress>  
  47. <stateCode>VIC</stateCode>  
  48. <postcode>3008</postcode>  
  49. <isCurrentIndicator>Y</isCurrentIndicator>  
  50. </mainBusinessPhysicalAddress>  
  51. </searchResultsRecord>  
  52. <searchResultsRecord>  
  53. <ABN>  
  54. <identifierValue>30146899103</identifierValue>  
  55. <identifierStatus>Cancelled</identifierStatus>  
  56. </ABN>  
  57. <mainName>  
  58. <organisationName>ANZ COMPANIES PTY LIMITED</organisationName>  
  59. <score>100</score>  
  60. <isCurrentIndicator>Y</isCurrentIndicator>  
  61. </mainName>  
  62. <mainBusinessPhysicalAddress>  
  63. <stateCode>NSW</stateCode>  
  64. <postcode>2134</postcode>  
  65. <isCurrentIndicator>Y</isCurrentIndicator>  
  66. </mainBusinessPhysicalAddress>  
  67. </searchResultsRecord>  
  68. <searchResultsRecord>  
  69. <ABN>  
  70. <identifierValue>22169448220</identifierValue>  
  71. <identifierStatus>Active</identifierStatus>  
  72. </ABN>  
  73. <mainName>  
  74. <organisationName>ANZ CORPORATION PTY LTD</organisationName>  
  75. <score>100</score>  
  76. <isCurrentIndicator>Y</isCurrentIndicator>  
  77. </mainName>  
  78. <mainBusinessPhysicalAddress>  
  79. <stateCode>NSW</stateCode>  
  80. <postcode>2009</postcode>  
  81. <isCurrentIndicator>Y</isCurrentIndicator>  
  82. </mainBusinessPhysicalAddress>  
  83. </searchResultsRecord>  
I need to fetch searchResultsRecord node for 50 times
  1. XmlNodeList nodesInfo = responseXml.SelectNodes("./searchResultsList/searchResultsRecord");  
  2. foreach (XmlNode result in responseXml.SelectNodes("Payload"))  
  3. {  
  4. XmlDocument doc1 = new XmlDocument();  
  5. result.AppendChild(doc1);  
  6. }  
My xpath is wrong it seems. How can i get proper xpath after the payload everynode is null.

Answers (2)