0

I got an XML which contained tag <content:encoded> which I have processed to this form. There are several tag and I am currently struggle at this particular tag. Example :

{
  title: [
    'the title goes here'
  ],
  link: [
    'https://anotherlink.com'
  ],
  description: [
    '<img src="https://something.com/foo.jpg"/>Some words here'
  ],
  'content:encoded': [
    'This content is what I want to get, also with escaped characters included'
  ],
  guid: [
    'https://something.com'
  ]
}

my pug page:

extends mp

block layout-content
  div.View
    h1.Banner Hello!
    data_in
    ul
      each element in data_in
          li
            div.Message
              div.Title
                h1= element.title                  >this gets expected output
                h3= element.content|encoded        >this gets wrong output

How do I get that encoded content , while with the same code do well when I getting the 'title' attribute ? Do I have to do another iteration ? Thank you

*edit : I mean , 'title' value

Ray
  • 31
  • 5
  • 2
    Can you clarify what "wrong output" is? Have you tried `h3= element['content:encoded']`? – Molda Sep 09 '21 at 08:12
  • The wrong output was "0" , just plain text "0" . But your solution works ! Thank you ! That doesn't cross me. This is out of topic, usually there's some attributes like How can I get the "something.com" ? – Ray Sep 09 '21 at 08:30
  • See this https://stackoverflow.com/questions/14939296/extract-image-src-from-a-string – Molda Sep 09 '21 at 09:30

0 Answers0