Click here to Skip to main content
15,896,486 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have a XML file which contains some values with sapace for a node. When i am trying to read the valeu from VC++ I am getting the values without the space. How can I read the complete value without getting the spaces trimmed off.

Example of XML file:
HTML
<Parameter>
    <ParameterName>UserOptions/OperatingSystemSettings/Password</ParameterName>
    <ParameterValue> sudhir </ParameterValue>
</Parameter>

In above XML observe the space at the beginning and the end of the value sudhir. Below is the code I have to read the value.
C++
hr = ((MSXML2::IXMLDOMElement*)objXmlNode)->getElementsByTagName(strParameterValueNode)->Getitem(0)->get_text(&strParameterValue);

Please let me know if any one knows how to read the complete values.

Regards,
Sudhir
Posted
Updated 4-Aug-11 0:07am
v4

This post is a quote from Stackoverflow: http://stackoverflow.com/questions/1927006/in-c-how-to-get-xml-node-value-that-is-white-space[^].

"Assuming you are using XmlDocument, you should set the PreserveWhiteSpace property to True. If using and XmlReader set the WhitespaceHandling property WhitespaceHandling.All. See this MSDN article about Preserving White Space While Serializing. The different serializers handle this different ways, try using the XmlTextReader for this, as per this forum post.

Original poster: Oded[^]
Best Regards,

—MRB
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 3-Aug-11 16:38pm    
That's it, my 5.
--SA
You just need to set the preserveWhiteSpace to true. Check the link for more info:
http://msdn.microsoft.com/en-us/library/ms761353%28v=vs.85%29.aspx#Y342[^]

Good luck!
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 3-Aug-11 16:38pm    
Right, my 5.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900