Pugixml get full string containing whitespace #681
-
I'm trying to read an XML file with the structure
The coordinate string is variable length with each tuple separated by a space. Pugixml correctly finds the node tags in the larger file, but when getting the coordinate text, it will only read the first value. Snippet of how it is being loaded/parsed:
Is this a limitation of pugixml, or is there a different way it can be parsed to preserve whitespace? I need to get the entire coordinate string, including the spaces. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Wild guess: second Otherwise, pugixml should preserve whitespace of text nodes in this case. |
Beta Was this translation helpful? Give feedback.
Wild guess: second
select_node
is finding a node that does not correspond to your object that's currently being processed. This is a common XPath gotcha, "//foo" means "go to document root and find all nodes with the name 'foo'". You needauto path_node = name_node.parent().select_node(".//coordinates");
instead.Otherwise, pugixml should preserve whitespace of text nodes in this case.