It can take a bit of work to figure out the correct schema to hold an intricate reply, but it CAN be done.
Below is a SIMPLE XML result, and I'd like to examine an alternate method to extract data.
Instead of Aware adding records to a physical table, I'm wondering about getting the result back into a single variable.
Then parsing that for what i want.
In this SIMPLE example, say I want the CITY of the LegalAddr.
Basically: CompanyInfo.LegalAddr.City = San Pablo3
If I only needed this for a specific immediate reason, seems a lot simpler to request the data and extract the City rather than run a process to read physical records to get the city. BOTH might be fast/immediate, but its night and day under the hood w.r.t. in-memory vs. physical IO.
Given that I would always know a path to the desired element, is it possible for a simple REGEX function to return my element?
What about an array? See the 2nd example... what if I wanted the UnitPrice of ID# 11. (the Pump, $15)? Can I get that with a REGEX?
In JS/Python (and others), there's all sorts of libraries to process this stuff? i wonder if calling a Java function would work better?
example: SessionVar.thePrice = FindXML(SessionVar.theString, 'CompanyInfo.LegalAddr.City')
Code: Select all
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<IntuitResponse
xmlns="http://schema.intuit.com/finance/v3" time="2021-08-19T07:35:02.350-07:00">
<CompanyInfo domain="QBO" sparse="false">
<Id>1</Id>
<SyncToken>11</SyncToken>
<MetaData>
<CreateTime>2021-04-21T13:36:13-07:00</CreateTime>
<LastUpdatedTime>2021-08-12T13:48:56-07:00</LastUpdatedTime>
</MetaData>
<CompanyName>Test Acct</CompanyName>
<LegalName>Test Acct</LegalName>
<CompanyAddr>
<Id>1</Id>
<Line1>123 Sierra Way</Line1>
<City>San Pablo1</City>
<Country>US</Country>
<CountrySubDivisionCode>CA</CountrySubDivisionCode>
<PostalCode>87999</PostalCode>
</CompanyAddr>
<CustomerCommunicationAddr>
<Id>1</Id>
<Line1>123 Sierra Way</Line1>
<City>San Pablo2</City>
<Country>US</Country>
<CountrySubDivisionCode>CA</CountrySubDivisionCode>
<PostalCode>87999</PostalCode>
</CustomerCommunicationAddr>
<LegalAddr>
<Id>1</Id>
<Line1>123 Sierra Way</Line1>
<City>San Pablo3</City>
<Country>US</Country>
<CountrySubDivisionCode>CA</CountrySubDivisionCode>
<PostalCode>87999</PostalCode>
</LegalAddr>
<PrimaryPhone></PrimaryPhone>
<CompanyStartDate>2021-04-21</CompanyStartDate>
<FiscalYearStartMonth>January</FiscalYearStartMonth>
<Country>US</Country>
<Email>
<Address>[email protected]</Address>
</Email>
<WebAddr></WebAddr>
<SupportedLanguages>en</SupportedLanguages>
<NameValue>
<Name>NeoEnabled</Name>
<Value>true</Value>
</NameValue>
<NameValue>
<Name>IsQbdtMigrated</Name>
<Value>false</Value>
</NameValue>
<NameValue>
<Name>CompanyType</Name>
<Value>Other</Value>
</NameValue>
<NameValue>
<Name>SubscriptionStatus</Name>
<Value>SUBSCRIBED</Value>
</NameValue>
<NameValue>
<Name>OfferingSku</Name>
<Value>QuickBooks Online Plus</Value>
</NameValue>
<NameValue>
<Name>PayrollFeature</Name>
<Value>false</Value>
</NameValue>
<NameValue>
<Name>AccountantFeature</Name>
<Value>false</Value>
</NameValue>
<NameValue>
<Name>QBOIndustryType</Name>
<Value>Landscaping Services</Value>
</NameValue>
<NameValue>
<Name>ItemCategoriesFeature</Name>
<Value>true</Value>
</NameValue>
<NameValue>
<Name>AssignedTime</Name>
<Value>2021-08-12T14:01:56-07:00</Value>
</NameValue>
</CompanyInfo>
</IntuitResponse>
Code: Select all
<IntuitResponse xmlns="http://schema.intuit.com/finance/v3" time="2021-08-19T08:00:00.476-07:00">
<QueryResponse startPosition="1" maxResults="5">
<Item sparse="true">
<Id>
25
</Id>
<Name>
Beam, large, 20ft
</Name>
<UnitPrice>
250
</UnitPrice>
</Item>
<Item sparse="true">
<Id>
11
</Id>
<Name>
Pump
</Name>
<UnitPrice>
15
</UnitPrice>
</Item>
<Item sparse="true">
<Id>
5
</Id>
<Name>
Rock Fountain
</Name>
<UnitPrice>
275
</UnitPrice>
</Item>
<Item sparse="true">
<Id>
16
</Id>
<Name>
Sprinkler Heads
</Name>
<UnitPrice>
2
</UnitPrice>
</Item>
<Item sparse="true">
<Id>
17
</Id>
<Name>
Sprinkler Pipes
</Name>
<UnitPrice>
4
</UnitPrice>
</Item>
</QueryResponse>
</IntuitResponse>