1

I'm trying to write an XML-Newsfeed for Wordpress that can be imported through a plugin and then put in to article-section where it can be edited and so on.

This is what i have:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE content>

<content>
<article id="1">
    <mainid>
        <![CDATA[DE20201201]]>
    </mainid>
    <titel>
        <![CDATA[Titel]]>
    </titel>
    <picture>
        <![CDATA[https://link.png]]>
    </picture>
    <article-content>
        <![CDATA[TEXT, JUST A LOT OF TEXT<br/> EVEN MORE TEXT]]>
    </article-content>
    <pubdate>2020-12-01 00:00:59</pubdate>
</article>
</content>

My Problem is that the "<br/>"'s in the element are not interpreted as an actual new line in the article in Wordpress.

I'm a total noob at this stuff, i know there's stuff like xsl and xslt but I'm not sure how all of that is working.

kjhughes
  • 106,133
  • 27
  • 181
  • 240
not sure
  • 13
  • 3

2 Answers2

1

Maybe have also a look to that Stack Overflow - How to add a newline (line break) in XML file?

And use instead of <br/>

Line Feed LF: "&#xA;"
Carriage Return CR: "&#xD;"
KargWare
  • 1,746
  • 3
  • 22
  • 35
  • 1
    Plus one for the link to the canonical newline / line-break Q/A. ;-) Whether this will work will depend upon how the processing application treats the passed-through ` ` and ` `. – kjhughes Dec 04 '20 at 14:52
  • these old guys will never disappear *lol* – KargWare Dec 04 '20 at 14:55
  • Lol, my old self or my my old answers? – kjhughes Dec 04 '20 at 14:56
  • Sorry I did not recognize that I share your own answer! I was thinking about the old LF or CR stuff ... – KargWare Dec 04 '20 at 16:03
  • No problem, you recognized its relevance before I did! – kjhughes Dec 04 '20 at 16:18
  • Hi, thank you, for your input, but this won't work here because the text in is stored elsewhere in a data abse and is then put in to the element so i can't directly edit the text in the xml-file, and i can't change the text in the data base because it is also use in other stuff where its needs to be html so the
    is needed. is there some way to replace the
    through some command?
    – not sure Dec 07 '20 at 10:06
  • @notsure: Now you're asking a coding question without having posted any code. Put up a [mcve] if you need debugging help. – kjhughes Dec 08 '20 at 15:04
  • Hey guys, thank you all for your help. The problem was solved another way. – not sure Dec 10 '20 at 06:52
0

CDATA is not interpreted as markup, so your <br/> is only interpreted as Character DATA.

Change

<article-content>
    <![CDATA[TEXT, JUST A LOT OF TEXT<br/> EVEN MORE TEXT]]>
</article-content>

to

<article-content>
    TEXT, JUST A LOT OF TEXT<br/> EVEN MORE TEXT
</article-content>

or

<article-content>
    <![CDATA[TEXT, JUST A LOT OF TEXT
EVEN MORE TEXT]]>
</article-content>

or

<article-content>
    <![CDATA[TEXT, JUST A LOT OF TEXT]]><br/> <![CDATA[EVEN MORE TEXT]]>
</article-content>

to have <br/> be interpreted as markup.

See also

kjhughes
  • 106,133
  • 27
  • 181
  • 240