Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parse XML file

Status
Not open for further replies.

AP81

Programmer
Apr 11, 2003
740
AU
I am trying to parse an XML file and extract information between certain tags.

This is what I have written so far:

var
strItem, strDesc : String; //variables to save
XMLdoc : IXMLDomDocument; //XML document to load
nlistItemCode, nlistDesc : IXMLDOMNodelist;
i : integer;
begin
XMLdoc := CreateOleObject('Microsoft.XMLDOM') as IXMLDomDocument;
//load XML file
XMLdoc.load('ItemUpdate.xml');

nlistItemCode := XMLDoc.getElementsByTagName('EditSequence');
for i := 0 to nlistItemCode.length -1 do
AddItemsToDB(nlistItemCode.item(i).nextSibling.nextSibling.text);

What I am trying to do is also extract the information from the <FullName> tag and the <desc> tag. What I have done can retrieve the FullName, but I want to also retrieve the description.

Here is a sample of the XML:
-----------------------------------------------------------
<?xml version=&quot;1.0&quot; ?>
<QBXML>
<QBXMLMsgsRs>
<ItemQueryRs requestID=&quot;1&quot; statusCode=&quot;0&quot; statusSeverity=&quot;Info&quot; statusMessage=&quot;Status OK&quot;>
<ItemNonInventoryRet>
<ListID>350000-1057030423</ListID>
<TimeCreated>2003-07-01T13:33:43+10:00</TimeCreated>
<TimeModified>2003-07-01T13:33:43+10:00</TimeModified>
<EditSequence>1057030423</EditSequence>
<Name>,LIGHT-LVL1</Name>
<FullName>,LIGHT-LVL1</FullName>
<IsActive>true</IsActive>
<Sublevel>0</Sublevel>
<TaxCodeRef>
<ListID>70000-1057029886</ListID>
<FullName>GST</FullName>
</TaxCodeRef>
<TaxCodeRef>
<ListID>70000-1057029886</ListID>
<FullName>GST</FullName>
</TaxCodeRef>
<SalesOrPurchase>
<Desc>EXTRA LIGHTING INCREASE</Desc>
<Price>55.00</Price>
<AccountRef>
<ListID>870000-1057030354</ListID>
<FullName>Casual Hire</FullName>
</AccountRef>
</SalesOrPurchase>
<ForeignPrice>0.00</ForeignPrice>
<AmountIncludesVAT>true</AmountIncludesVAT>
</ItemNonInventoryRet>
-----------------------------------------------------------

Any ideas?




------------------------------------
There's no place like 127.0.0.1
------------------------------------
 
Check out Delphi's wrapper for XMLDOM, TXMLDocument (internet tab on component palette).

Simon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top