• I am stumped as to how I can enter XML snippets in blog entry.
    Enclosing indented XML in ‘pre’ tags almost works. What is output is the xml code with the tags escaped (i.e. < replaced by <), but all the leading spaces are gone! I’ve tried using a CDATA section inside the pre tags, but WordPress just escapes that, so it is visible in the final output, and the xml has still lost its indentation.
    Can anybody offer tips on how to get indented XML into a blog entry? My weblog is programming related, so I am going to need to show xml snippets frequently…
    Colin

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter colins

    (@colins)

    Actually, the behaviour above is with the Textile plugin enabled. With it disabled, wrapping the xml in ‘pre’ tags alone does not work, since the xml is sent out as is and confuses the browser, while trying to add a CDATA inside the ‘pre’ tags also doesn’t work, since it seems WP escapes the CDATA element by adding a space after the initial ‘<‘.

    Does the widgetencoder help ?
    http://resources.ww.wp.xz.cn/tools/encode/

    Thread Starter colins

    (@colins)

    Yes, that’s one solution. I was actually looking around in the meantime for some online service to escape XML/HTML.
    It would still be nicer if this could be handled in WP directly though, as it’s still not very convenient to if you ever want to edit the original text. You basically have to copy the output text, modify it again, and then re-escape it and put it back in. Pretty laborious…
    Colin

    Thread Starter colins

    (@colins)

    Scott,
    It almost works, but does seem to have a weird issue where it eats some <props> tags. I have a big post with mixed text and xml fragments. The following
    <pre>
    <props>
    <prop key=”get*”>PROPAGATION_REQUIRED,readOnly</prop>
    <prop key=”find*”>PROPAGATION_REQUIRED,readOnly</prop>
    <prop key=”load*”>PROPAGATION_REQUIRED,readOnly</prop>
    <prop key=”store*”>PROPAGATION_REQUIRED</prop>
    </props>
    </pre>
    (don’t know if the comment parser here will kill the stuff above) comes out with the ‘props’ elements taken out for some reason. In other parts of the post, the same thing was happening initially with the same elements, but now it’s ok. I have no clue what is going on. I can mail you the whole post if you wish to try it out…

    Thread Starter colins

    (@colins)

    Ok, that xml fragment got almost all swallowed. Let’s try again
    <pre>
    <props>
    <prop key=”get*”>PROPAGATION_REQUIRED,readOnly</prop>
    <prop key=”find*”>PROPAGATION_REQUIRED,readOnly</prop>
    <prop key=”load*”>PROPAGATION_REQUIRED,readOnly</prop>
    <prop key=”store*”>PROPAGATION_REQUIRED</prop>
    </props>
    </pre>

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘How to enter xml code samples in a blog entry’ is closed to new replies.