-
Notifications
You must be signed in to change notification settings - Fork 728
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sometimes pugixml fails to find xpath values #57
Comments
|
Thanks for such a quick response. Using 'load_buffer' instead seems to have fixed the problem. However I am certain that the buffer is not modified until after all the pugixml methods have been called. |
Can you provide a more complete version of the code (including details such as where the value is defined, how message_text is allocated & destroyed etc.)? |
Both value & message_text are local variables of the caller to the parser function, both char[]. The prototype for the parser function is: extern "C" { Prior to me using the load_buffer_inplace, message_text was "const char*" |
The only way I can imagine the code you posted malfunctioning is if [value, value + size] and [message_text, message_text + strlen(message_text)) overlap. If they do then strncpy will fill part of message_text with zeroes, which will essentially make some nodes in the document lose their names & contents. If the above is true it's likely that the node you find will be very unusual - this:
Would print:
Also note that the code |
There is definitely no overlap. And value is defined as [size+1] |
I don't really know at this point how to make progress on this. I still suspect an application bug but I can't be sure. Can you provide the source for iso20022_get_field function, the source for the function that calls it, an example XPath expression and an example XML where you could see the issue? (I understand that the issue is intermittent - this does not matter). Feel free to e-mail them to arseny.kapoulkine at gmail dot com if you don't want to attach them to the issue. |
Wait, this is obvious. I'm not sure how I missed this. I was assuming that the code checks the XML parse result but I don't see this in the code. If you call iso20022_get_field twice on the same buffer, the first call will destructively modify the buffer if you use load_buffer_inplace, and the second call will get a buffer that likely has the first tag abruptly ending, e.g. "<foo" - in which case the parsing will fail, and XPath query will not find anything. |
That must be it. |
Hello , Any API that i can use to find the node (anywhere in xml) without xpath? (I know the node name) |
I have the following code to extract data from an XML document using XPATH:
...
Sometimes this works fine and sometimes the contents of 'value' is an empty string even if
the document contains data in the element. How can I troubleshoot this? I have not used
pugixml before and I am on a very tight deadline.
The text was updated successfully, but these errors were encountered: