Marcel Güttler
2005-10-04 12:21:17 UTC
Hi,
my problem is to access IXMLNodeCollection of a subnode XML. For
example i need the two positions of order 25 -> 1,2
(IXMLNodeCollection).
i read also http://qc.borland.com/wc/qcmain.aspx?d=2735 but i did't
understand the solution.
if i try to get the count of a subbranch i alway get a count of 0
thanks for your help
Marcel
------
Example:
<OrderData>
<Order>
<OrderNr>25</OrderNr>
<OrderPosition>
<OrderPositionID>1</OrderPositionID>
</OrderPosition>
<OrderPosition>
<OrderPositionID>2</OrderPositionID>
</OrderPosition>
</Order>
<Order>
<OrderNr>26</OrderNr>
<OrderPosition>
<OrderPositionID>3</OrderPositionID>
</OrderPosition>
<OrderPosition>
<OrderPositionID>4</OrderPositionID>
</OrderPosition>
</Order>
</OrderData>
###############
var
myXML : TXMLDocument;
myOrderData : IXMLOrderDataType;
myOrder : IXMLOrderType;
myOrderPositionNode : IXMLOrderPositionType;
myOrderPositionList : IXMLOrderPositionTypeList;
Order_i,OrderPos_i: Integer;
begin
myXML := TXMLDocument.create(nil);
myXML.FileName := filenname;
//### find all orders
myOrderData := DelphiXML_Import.GetOrderData(myXML); //
DelphiXML_Import is a unit from the Delphi XML Databinding expert
for Order_i := 0 to myOrderData.Count-1 do //count is correct ->in
this example two
begin
myOrder.OrderNr := doSomething; //is ok
//search all positions of a order
myOrderPositionList:= myOrder.OrderPosition; //return
IXMLOrderPositionTypeList, but EAccesViolation
myOrderPositionList:= myOrderData.myOrder[Order_i].OrderPosition;
//works, but myOrderPositionList.Count alwaly return 0 -> i need 2
for OrderPos_i := 0 to myOrderPositionList.Count-1 do //count i not
correct
begin
//...
myOrderPosition := myOrder.myOrderPositionList.Items[OrderPos_i];
//doesn't work
doSomething(myOrderPosition);
end;
end;
end;
my problem is to access IXMLNodeCollection of a subnode XML. For
example i need the two positions of order 25 -> 1,2
(IXMLNodeCollection).
i read also http://qc.borland.com/wc/qcmain.aspx?d=2735 but i did't
understand the solution.
if i try to get the count of a subbranch i alway get a count of 0
thanks for your help
Marcel
------
Example:
<OrderData>
<Order>
<OrderNr>25</OrderNr>
<OrderPosition>
<OrderPositionID>1</OrderPositionID>
</OrderPosition>
<OrderPosition>
<OrderPositionID>2</OrderPositionID>
</OrderPosition>
</Order>
<Order>
<OrderNr>26</OrderNr>
<OrderPosition>
<OrderPositionID>3</OrderPositionID>
</OrderPosition>
<OrderPosition>
<OrderPositionID>4</OrderPositionID>
</OrderPosition>
</Order>
</OrderData>
###############
var
myXML : TXMLDocument;
myOrderData : IXMLOrderDataType;
myOrder : IXMLOrderType;
myOrderPositionNode : IXMLOrderPositionType;
myOrderPositionList : IXMLOrderPositionTypeList;
Order_i,OrderPos_i: Integer;
begin
myXML := TXMLDocument.create(nil);
myXML.FileName := filenname;
//### find all orders
myOrderData := DelphiXML_Import.GetOrderData(myXML); //
DelphiXML_Import is a unit from the Delphi XML Databinding expert
for Order_i := 0 to myOrderData.Count-1 do //count is correct ->in
this example two
begin
myOrder.OrderNr := doSomething; //is ok
//search all positions of a order
myOrderPositionList:= myOrder.OrderPosition; //return
IXMLOrderPositionTypeList, but EAccesViolation
myOrderPositionList:= myOrderData.myOrder[Order_i].OrderPosition;
//works, but myOrderPositionList.Count alwaly return 0 -> i need 2
for OrderPos_i := 0 to myOrderPositionList.Count-1 do //count i not
correct
begin
//...
myOrderPosition := myOrder.myOrderPositionList.Items[OrderPos_i];
//doesn't work
doSomething(myOrderPosition);
end;
end;
end;