No need to apologize at all, and you’ve definitely found the right place to ask. XML parsing tends to be especially tricky in my opinion, and it seems like I have to re-learn it every time I look.
So I’ll start with your first query, since that looks really close to what we want, and post the process I went through to get to an answer, and at the end I think I have something that’ll work for you.
I copied your file content to c:\temp\test.xml for my testing and to illustrate the part of the query we care about.
Starting with what you had, we can see this is really close to what we want:
Q: node values of xpaths "/PreMigration/storeSize/size/@clusterSize" of xml document of file "c:\temp\test.xml" A: 0 A: 0 A: 512 A: 1024 A: 2048 A: 4096 A: 8192 A: 16384 A: 32768 A: 65536 A: 131072 A: 262144 A: 524288 A: 1048576 T: 0.452 ms I: plural string
But I don’t know what properties are available for an ‘xpath’, so I’ll go up one level and figure out what type it is, and then what properties are available for that type. The first query may give me an error, but at least it’ll show me what type I’m looking at:
q: xpaths "/PreMigration/storeSize/size/@clusterSize" of xml document of file "c:\temp\test.xml" E: This expression evaluates to an unrepresentable object of type "xml dom node" T: 0.443 ms I: plural xml dom node
q: properties of type "xml dom node" A: node name of <xml dom node>: string A: node type of <xml dom node>: integer A: node value of <xml dom node>: string A: owner document of <xml dom node>: xml dom document A: parent node of <xml dom node>: xml dom node A: first child of <xml dom node>: xml dom node A: last child of <xml dom node>: xml dom node A: previous sibling of <xml dom node>: xml dom node A: next sibling of <xml dom node>: xml dom node A: child node <integer> of <xml dom node>: xml dom node A: child nodes of <xml dom node>: xml dom node A: attribute <integer> of <xml dom node>: xml dom node A: attribute <string> of <xml dom node>: xml dom node A: attributes of <xml dom node>: xml dom node A: selects <string> of <xml dom node>: xml dom node A: xpaths <string> of <xml dom node>: xml dom node A: xpaths <( string, string )> of <xml dom node>: xml dom node T: 0.288 ms I: plural property
From this, I think both “node values”, “child nodes” and “attributes” look interesting. I’ll see if I can figure out what the node names and node values are from our original query:
q: (node names of it, node values of it) of xpaths "/PreMigration/storeSize/size/@clusterSize" of xml document of file "c:\temp\test.xml" A: clusterSize, 0 A: clusterSize, 0 A: clusterSize, 512 A: clusterSize, 1024 A: clusterSize, 2048 A: clusterSize, 4096 A: clusterSize, 8192 A: clusterSize, 16384 A: clusterSize, 32768 A: clusterSize, 65536 A: clusterSize, 131072 A: clusterSize, 262144 A: clusterSize, 524288 A: clusterSize, 1048576 T: 0.659 ms I: plural ( string, string )
As expected, we’re getting the same “values” as the previous query, but this shows us that the “node” we are looking at is “clusterSize”. XML is treating the “clusterSize” attribute as a node all it’s own. Really, I think we need the node above the “clusterSize” value, to get to the “size” node. The “size” node would have an attribute of clusterSize, and a value of the … whatever that big number represents. So I move the xpath up one level, and look at the child nodes of its results. (I probably could have left the xpath as it was, and instead start looking at “parent node of it”, but I’ll leave that as an exercise for the reader. There are probably ten other ways to do this with ‘selects’ as well.)
In this query, I want to check that I’m on the right path to find the “size” node, which should have the “clusterSize” attribute and the large node values:
(edit added “node name of it” to show we’re looking at the ‘size’ node, which has a single child node (the large integer value) )
q: ((node names of it, node values of it) of attributes of it, node name of it, node value of child nodes of it) of child nodes of xpaths "/PreMigration/storeSize" of xml document of file "c:\temp\test.xml" A: ( clusterSize, 0 ), size, 103971021896 A: ( clusterSize, 0 ), size, 103971021896 A: ( clusterSize, 512 ), size, 103971937792 A: ( clusterSize, 1024 ), size, 103972934656 A: ( clusterSize, 2048 ), size, 103974961152 A: ( clusterSize, 4096 ), size, 103978913792 A: ( clusterSize, 8192 ), size, 103987011584 A: ( clusterSize, 16384 ), size, 104003108864 A: ( clusterSize, 32768 ), size, 104035909632 A: ( clusterSize, 65536 ), size, 104104394752 A: ( clusterSize, 131072 ), size, 104240513024 A: ( clusterSize, 262144 ), size, 104513667072 A: ( clusterSize, 524288 ), size, 105062596608 A: ( clusterSize, 1048576 ), size, 106180902912 T: 1.187 ms I: plural ( ( string, string ), string, string )
Bingo! Now to find the one node that we want - the one with a clusterSize of 4096:
q: ((node names of it, node values of it) of attributes of it, node values of child nodes of it) of child nodes whose (node value of attribute "clusterSize" of it = "4096") of xpaths "/PreMigration/storeSize" of xml document of file "c:\temp\test.xml" A: ( clusterSize, 4096 ), 103978913792 T: 0.635 ms I: plural ( ( string, string ), string )
Now it’s just a matter of taking the value of the right child node, convert it to integer, and do the divisions however you want to represent it. If it’s in bytes as I expect, then I divide by 1024 to get KB, divide by 1024 again to get MB, and divide by 1024 again to get GB:
q: (it / 1024 / 1024 / 1024) of (node values of child nodes of it as integer) of child nodes whose (node value of attribute "clusterSize" of it = "4096") of xpaths "/PreMigration/storeSize" of xml document of file "c:\temp\test.xml" A: 96 T: 0.540 ms I: plural integer