Discussion:
IXMLNodeCollection count doesn't work (XML Databinding)
(too old to reply)
Marcel Güttler
2005-10-04 12:21:17 UTC
Permalink
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;
khariv
2005-10-04 13:38:51 UTC
Permalink
Post by Marcel Güttler
if i try to get the count of a subbranch i alway get a count of 0
I ran into this problem a few days ago. After much searching, I eventually
had to write my own code to traverse the XMLDocument to load the nodes
correctly into my objects. By the way, I am having this problem only in
Delphi 2005 (specifically a VCL.NET project). Not sure if this is also
your configuration.
Post by Marcel Güttler
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.
I do not believe that the "answer" is accurate at all. The code I am
using WAS generated by the data binding wizard. As a matter of fact,
pretty much the same code (with minor modifications) works perfectly in
Delphi 7. It is just in Delphi 2005 that the nodes.count property does
not work. Hopefully in Dexter, we'll get a .NET XML data binding object
setup that actually works.



--- posted by geoForum on http://delphi.newswhat.com

Loading...