Reading in XML File, slightly unusual format

jkeogh
Member Posts: 5
I have an XML file of the following format.
and am accessing it as follows.
So that gets me from the top of the file down to ns2:result, and then obviously it fails doing the FindNode of 'Name' as its clearly not a Node.
But how exactly do I access 'Name' and 'Value' inside ns2:result ?
edit :
Solved using specially written 'get atttribute' function, and looping through these attributes returning their value.
pm jkeoghatsyscodotie if want the code used.
- <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> <SOAP-ENV:Header /> - <SOAP-ENV:Body> - <ns2:ReportResponse xmlns:ns2="http://www.webexpenses.com/reports/schemas" xmlns:ns3="http://www.webexpenses.com/ws/schemas" xmlns:ns4="http://www.webexpenses.com/ws/mobile/schemas"> <ns2:responseTitle /> - <ns2:responseBody> - <ns2:resultRow> <ns2:result Name="vatRate" Value="21.0" /> <ns2:result Name="status" Value="Submitted" /> <ns2:result Name="claimId" Value="12" /> <ns2:result Name="companyName" Value="Healthcare Ltd" /> <ns2:result Name="dateCreated" Value="26-07-2011" /> <ns2:result Name="claimItemDesc" Value="Visit customer in Cork" /> <ns2:result Name="amount" Value="200.0000" /> <ns2:result Name="amountWithoutVat" Value="165.2900" /> <ns2:result Name="claimDesc" Value="" /> <ns2:result Name="accountsPersonName" Value="Accounts, Test ROI" /> <ns2:result Name="categoryGlCode" Value="52500" /> <ns2:result Name="categoryName" Value="Hotels" /> <ns2:result Name="datePaid" Value="" /> </ns2:resultRow> - <ns2:resultRow> <ns2:result Name="vatRate" Value="21.0" /> <ns2:result Name="status" Value="Submitted" /> <ns2:result Name="claimId" Value="12" /> <ns2:result Name="companyName" Value="Healthcare Ltd" /> <ns2:result Name="dateCreated" Value="26-07-2011" /> <ns2:result Name="claimItemDesc" Value="Car hire RE visit to customer in cork" /> <ns2:result Name="amount" Value="200.0000" /> <ns2:result Name="amountWithoutVat" Value="165.2900" /> <ns2:result Name="claimDesc" Value="" /> <ns2:result Name="accountsPersonName" Value="Accounts, Test ROI" /> <ns2:result Name="categoryGlCode" Value="52800" /> <ns2:result Name="categoryName" Value="Car Hire" /> <ns2:result Name="datePaid" Value="" /> </ns2:resultRow> ............... etc
and am accessing it as follows.
XMLNode := XMLDocument.documentElement; XMLRootNode := XMLDocument.documentElement; WITH XMLDOMManagement DO BEGIN XMLDOMManagement.SetNormalCase; IF FindNode(XMLNode,'SOAP-ENV:Body',XMLNodeFound) THEN BEGIN XMLNode := XMLNodeFound; IF FindNode(XMLNode,'ns2:ReportResponse',XMLNodeFound) THEN BEGIN XMLNode := XMLNodeFound; IF FindNode(XMLNode,'ns2:responseBody',XMLNodeFound) THEN BEGIN XMLNode := XMLNodeFound; IF FindNode(XMLNode,'ns2:resultRow',XMLNodeFound) THEN BEGIN XMLNode := XMLNodeFound; IF FindNode(XMLNode,'ns2:result',XMLNodeFound) THEN BEGIN XMLNode := XMLNodeFound; IF FindNode(XMLNode,'Name',XMLNodeFound) THEN BEGIN XMLNode := XMLNodeFound; END; END; END; END; END; END; END;
So that gets me from the top of the file down to ns2:result, and then obviously it fails doing the FindNode of 'Name' as its clearly not a Node.
But how exactly do I access 'Name' and 'Value' inside ns2:result ?
edit :
Solved using specially written 'get atttribute' function, and looping through these attributes returning their value.
pm jkeoghatsyscodotie if want the code used.
0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions