XPath selector based on element above

I’m not sure if my request is even possible, but since WordPress XML export is a mess I need to find a way of getting what I need. Here is some example XML output that I have.

<xml>
  <wp:postmeta>
    <wp:meta_key>_thumbnail_id</wp:meta_key>
    <wp:meta_value><![CDATA[108]]></wp:meta_value>
  </wp:postmeta>
  <wp:postmeta>
    <wp:meta_key>_aioseop_keywords</wp:meta_key>
    <wp:meta_value><![CDATA[keyword1, keyword2]]>
  </wp:meta_value>
</xml>

Now I am trying to get the value of keywords, I have tried to use an exact path selector but the problem is sometimes the keyword element area may sit above the _thumbnail_id.

Read More

I want to get the value of ‘wp:meta_value’ based on ‘wp:meta_key’ value being equal to ‘_aioseop_keywords’.

How can this be achieved, the other less favourable alternative is how to get WordPress to properly extract decent XML.

Related posts

Leave a Reply

1 comment