Im currently working with QBXML which is the same as XML 1.0 and its fully standard compliant.
I receive this XML from QuickBooks.
<?xml version="1.0" ?>
<QBXML>
<QBXMLMsgsRs>
<CustomerQueryRs requestID="1" statusCode="0" statusSeverity="Info" statusMessage="Status OK">
<CustomerRet>
<ListID>91D0000-1015432175</ListID>
<Name>01 @ Systems (New York)</Name>
<Contact>Rob Smiles</Contact>
</CustomerRet>
</CustomerQueryRs>
</QBXMLMsgsRs>
</QBXML>
I read it using XPathNavigator like this
Begin Xml
Dim CustXML As XmlDocument = New XmlDocument()
CustXML.LoadXml(response)
Dim nav As XPathNavigator = CustXML.CreateNavigator()
Setting XML Navigational Paths
Customer Information
Dim iListID As XPathNodeIterator = nav.Select(nav.Compile("/*/*/*/CustomerRet/ListID"))
Dim iName As XPathNodeIterator = nav.Select(nav.Compile("/*/*/*/CustomerRet/Name"))
Dim iContact As XPathNodeIterator = nav.Select(nav.Compile("/*/*/*/CustomerRet/Contact"))
Using ListID as Main iterator all Customer have a ListID according to Quickbooks
While (iListID.MoveNext())
Get Customer ID
ListID = iListID.Current.Clone.Value.ToString()
Get Customer Name
iName .MoveNext()
CustName = iName .Current.Clone.Value.ToString()
Get Customer Contact
iContact .MoveNext()
Contact = iContact .Current.Clone.Value.ToString()
End while
So the problem is QuickBooks only returns XML nodes out of filled fields.
Example: If in QuickBooks I have the field "Contact" empty it will not return the contact node in the XML.
So this leaves me with 1,300 Customers in a not good shape XML File which I cannot read since it skips nodes and gives me wrong values.
How can I detect if that portion of the xml doenst have than node?
I have like 300 Customers with "Contact" node not being in the XML.
Note: This is not the complete XML, its just an example of what is happening.
I receive this XML from QuickBooks.
<?xml version="1.0" ?>
<QBXML>
<QBXMLMsgsRs>
<CustomerQueryRs requestID="1" statusCode="0" statusSeverity="Info" statusMessage="Status OK">
<CustomerRet>
<ListID>91D0000-1015432175</ListID>
<Name>01 @ Systems (New York)</Name>
<Contact>Rob Smiles</Contact>
</CustomerRet>
</CustomerQueryRs>
</QBXMLMsgsRs>
</QBXML>
I read it using XPathNavigator like this
Begin Xml
Dim CustXML As XmlDocument = New XmlDocument()
CustXML.LoadXml(response)
Dim nav As XPathNavigator = CustXML.CreateNavigator()
Setting XML Navigational Paths
Customer Information
Dim iListID As XPathNodeIterator = nav.Select(nav.Compile("/*/*/*/CustomerRet/ListID"))
Dim iName As XPathNodeIterator = nav.Select(nav.Compile("/*/*/*/CustomerRet/Name"))
Dim iContact As XPathNodeIterator = nav.Select(nav.Compile("/*/*/*/CustomerRet/Contact"))
Using ListID as Main iterator all Customer have a ListID according to Quickbooks
While (iListID.MoveNext())
Get Customer ID
ListID = iListID.Current.Clone.Value.ToString()
Get Customer Name
iName .MoveNext()
CustName = iName .Current.Clone.Value.ToString()
Get Customer Contact
iContact .MoveNext()
Contact = iContact .Current.Clone.Value.ToString()
End while
So the problem is QuickBooks only returns XML nodes out of filled fields.
Example: If in QuickBooks I have the field "Contact" empty it will not return the contact node in the XML.
So this leaves me with 1,300 Customers in a not good shape XML File which I cannot read since it skips nodes and gives me wrong values.
How can I detect if that portion of the xml doenst have than node?
I have like 300 Customers with "Contact" node not being in the XML.
Note: This is not the complete XML, its just an example of what is happening.