Click here to Skip to main content
15,349,128 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I Load and read file XML, and i have 1 label show Component in data XML.

Please help me count results. Thanks!

What I have tried:

For example: I have label show number in results read from Xml(total 3 file). With results 1 in file 1 label show (300), results 2 in file 2 is(100), results 3 in file 3 is (100) . I want label total sum 3 reults is 500

Edit: Posted as "solution 1" by OP:

Update question:
XML file
<ns1:BoardTestXMLExport xmlns:ns1="" numberOfIndictedComponents="5" testerTestStartTime="2021-01-30T00:31:32.000+07:00" testTime="2021-01-30T00:31:22.000+07:00" repairStationId="HCMINGAOI11" testStatus="Reviewed Passed" testerTestEndTime="2021-01-30T00:31:37.000+07:00" numberOfIndictedPins="0" numberOfComponentsTested="319" numberOfJointsTested="0" numberOfDefects="5" repairStatus="Reviewed Passed">
    <ns1:BoardXML imageId="3" serialNumber="21028217724" assemblyRevision="ING-296244891AE_M-A-B" boardType="ING-296244891AE_M-A-B" boardRevision="1607419487000"/>
    <ns1:StationXML testerName="HCMINGAOI05" stage="V510"/>

I get Element numberOfComponentsTested and show to label : 319

I want to load the next file this number will add up with the previous result. example file 1 numberOfComponentsTested = 319 , next file numberOfComponentsTested = 200;

label total will show 519.You know what I mean?
How do I calculate that?
Updated 1-Feb-21 4:29am
OriginalGriff 30-Jan-21 1:56am

What have you tried?
Where are you stuck?
What help do you need?

What does it do that you didn't expect, or not do that you did?
What have you tried to do to find out why?
Are there any error messages, and if so, where and when? What did you do to make them happen?

This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with - and we have no access to yoru code, or the XML data, so we have no real idea what data you are working with, or how you are dealing with it!
Use the "Improve question" widget to edit your question and provide better information.
Dave Kreskowiak 30-Jan-21 1:57am
OK, so you forgot to ask a question or describe a problem you're having.
Sơ Mi Tv 30-Jan-21 3:34am
Ok, i update the question, please see it agian
OriginalGriff 30-Jan-21 3:41am
No, you didn't.
The last time the question was modified was 1hr 20mins ago; your comment was 5 mins ago.

You did not update your question before you closed the window!
Sơ Mi Tv 30-Jan-21 5:33am
you can see Solution1 Posted 1hr 20mins ago :)
thatraja 30-Jan-21 8:17am
He told you to update question using Improve question button.
Richard Deeming 1-Feb-21 9:57am
If you want to update your question, click the green "Improve question" link and update your question.

Do not post your update as a "solution" to your question.
Gerry Schmitz 1-Feb-21 10:22am
You're saying you didn't write any code and you want someone else to do it: read one or more XML file while summing "numberOfComponentsTested".

1 solution

Uhhh...seems simple enough. Create a variable, like totalComponents, and, I don't know, add the total count from each file you load to it? When you're done loading your files, show the value of totalComponents in the label.

If you're storing the "value" in the label, hoping to add another value to it, you're doing it wrong. The UI controls are there to show and manipulate the state of your data model, not to store values for it.
Sơ Mi Tv 5-Feb-21 10:42am
yeap, I've find out solution write for each value in file XML to Sql server and count it :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900