Comments (10)
- You can locate the node without the text using node.node().offset_debug() - this is the byte offset from the beginning of the file where the node is
- You can check node.node().child_value() (should be the same but who knows)
- You're using load_buffer_inplace; make sure message_text is not being modified after load_buffer_inplace or reused - load_buffer_inplace is a destructive operation. Check if load_buffer works instead.
- If you attach the document and/or XPath query you're using I may have more ideas. If you don't want to make them public feel free to send them to me by e-mail: [email protected]
from pugixml.
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.
from pugixml.
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.)?
from pugixml.
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" {
int iso20022_get_field(const char *xpath,
char *value, char *message_text,
int size);
}
Prior to me using the load_buffer_inplace, message_text was "const char*"
from pugixml.
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:
printf("%d <%s>\n", node.node().type(), node.node().name());
Would print:
2 <>
Also note that the code value[size] = 0
is suspicious - from the declaration of the function it seems that value is a buffer with size bytes, not size+1?
from pugixml.
There is definitely no overlap. And value is defined as [size+1]
from pugixml.
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.
from pugixml.
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.
from pugixml.
That must be it.
from pugixml.
Hello , Any API that i can use to find the node (anywhere in xml) without xpath? (I know the node name)
from pugixml.
Related Issues (20)
- Version 1.14 HOT 1
- Can you add the ability to access child nodes using index? HOT 1
- PUGIXML_WCHAR_MODE and error messages. HOT 1
- add xml_node_type_str function for debugging and application logging HOT 3
- option to join multiple CDATA sections into one when parsing HOT 2
- parse_embed_pcdata and parse_merge_pcdata don't play together HOT 2
- Unexpected #endif in line 13201 with precompilation in a pch.h file HOT 2
- XML Canonicalization: as an option, allow parsing eol's into the document model (as PCDATA holding those) HOT 2
- Warning when building 1.14 in x86 on Clang HOT 3
- Position of the parse result offset in case of status_bad_start_element
- Error in handling loading errors example HOT 1
- Incorrect result of xml_document::load_file -"File was not found" HOT 2
- Question: I have made my own case insensitive version, is that ok? HOT 2
- Serilisation HOT 4
- pugi::xml_node and std::ranges, maybe a documentation request HOT 2
- call function xml_node::empty() always return false in anyway HOT 3
- Not able to attach a xsl via a `<?xml-stylesheet ...?>` node HOT 1
- xmldocument::save uses non-transformed encoding parameter HOT 4
- Warnings (C5245) when having PUGIXML_NO_STL and PUGIXML_API defined HOT 6
- PUGIXML_WCHAR_MODE featrue for vcpkg HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pugixml.