Read XML nodeValue when it conatins all character as white space.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Harinarayana G
    New Member
    • Oct 2011
    • 1

    Read XML nodeValue when it conatins all character as white space.

    Hi Sir,

    I am trying to retrieve the XML nodeValue when it contains white spaces(All charcaters are white space). But it is returning null value. Can you please help regarding this.
    For example XML document contains below Node,
    <Tiger>
    <Lion> <Lion>
    </Tiger>
    Here Lion node contains white space as its value
    But while retrieving it value by using following API I am getting null value.
    MSXML2::IXMLDOM NodeListPtr node;
    1. value = node->GetnodeValue ()
    2. value = node->text();
    3. get_text(&value )
    Thanks in advance.
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    All white space in xml is ignored so the xml

    <Tiger>
    <Lion> <Lion>
    </Tiger>

    has no value in Lion which is why you are getting NULL. You need to specifically mark the data as character data if you wish to receive it like so

    <Tiger>
    <Lion><![CDATA[ ]]><Lion>
    </Tiger>

    The CDATA marker tells the XML parser not to parse the contents of that section and so the white space is preserved.

    Comment

    Working...