tixiGetNumberOfChilds gives 1 for an empty list #231
Replies: 7 comments
-
Confirmed for Python: > set PATH=C:\Users\bach_ar\Downloads\TIXI-3.3.0-win64\bin;%PATH%
> python
import tixi3wrapper
cpacs = tixi3wrapper.Tixi3()
cpacs.openString("""?xml version="1.0" encoding="utf-8"?>
<project>
<elements>
</elements>
</project>""")
cpacs.getNumberOfChilds("/project/elements")
1 I can fix it by removing the newline and spaces between |
Beta Was this translation helpful? Give feedback.
-
Spaces and new Lines constitute technically to (invisible) XML text elements, so that's why you'll get "1" as the number of childs. So technically (by xml definition), the result 1 is correct. I understand though, that in this case, you want probably iterate over the "element" nodes, so you expect a zero count. I think a better API would be something tixiGetNumberOfChildElements(handle, "/project/elements", "element", &count) where you explicitly need to defined the element name you are searching for. You can though use the function tixiXPathEvaluateNodeNumber(handle, "/project/elements//element", &count) |
Beta Was this translation helpful? Give feedback.
-
Here's an example from tixi3 import tixi3wrapper
cpacs = tixi3wrapper.Tixi3()
cpacs.openString("""<?xml version="1.0" encoding="utf-8"?>
<project>
<elements>
</elements>
</project>""")
# prints 0
print(cpacs.xPathEvaluateNodeNumber("/project/elements//element"))
cpacs = tixi3wrapper.Tixi3()
cpacs.openString("""<?xml version="1.0" encoding="utf-8"?>
<project>
<elements>
<element/>
</elements>
</project>""")
# prints 1
print(cpacs.xPathEvaluateNodeNumber("/project/elements//element")) |
Beta Was this translation helpful? Give feedback.
-
I guess, this would be equivalent to the |
Beta Was this translation helpful? Give feedback.
-
@CLiersch You are absolutely right 🤦 . It seems, that it is too long ago, since I was using tixi last time. |
Beta Was this translation helpful? Give feedback.
-
I am closing the issue, since the function is doing what it should do. Use instead |
Beta Was this translation helpful? Give feedback.
-
Thanks for your input! I moved this issue to the discussion board. |
Beta Was this translation helpful? Give feedback.
-
For the xml file:
And the corresponding function call:
we get 1 and not as I would expect to 0. Is this intentional, and if so, how would one get the actual list size?
Beta Was this translation helpful? Give feedback.
All reactions