CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Hybrid View

  1. #1
    Join Date
    May 2002
    Location
    Germany
    Posts
    451

    [RESOLVED] php DOMDocument load / loadXML when attributes contain end of line characters

    I try to load the following XML node into a DOMDocument:
    Code:
    <test value="1\n2\n3\n4\n5">test</test>
    It is a big sorrow that DOMDocument::load() and DOMDocument::loadXML() of both replaces \n to five spaces (using php 5). Looking into the relevant RFC, \n is a perfectly valid character for XML attributes. Qt C++ and java handles it properly as well.

    I see that there are options on load and loadXML to change certain behaviors, just I could not find out which one to use for this purpose.

    So, how is it possible to force keeping end of line characters (replacing to PHP_EOL does not work either so DOMDocument is the nasty one, the incoming strings are alright). I have some code parsers where code is in the attribute so replacing/escaping is not really an option (of course, I could put there base64 and then decode at use, but that is a very high overhead). Must keep the EOLs.

  2. #2
    Join Date
    May 2002
    Location
    Germany
    Posts
    451

    Re: php DOMDocument load / loadXML when attributes contain end of line characters

    I looked for this for a bit of time and just found after asking the question:
    $Data = str_replace("\n", "xx", $Data);
    xx = <amp heshmark one zero semicolon>

    in case if others stumble into the same issue

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured