Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I spider some web pages and pull some information from them.

At this point you will either have the results of parsing HTML or you will have raw HTML.

when ® is passed to it, it is converted to ®

This suggests you are dealing with parsed HTML, with any entities already converted to real characters.

In this case, there are two approaches you could take.

  1. Use a module designed for writing XML
  2. Use a generic template module

If you use a module designed for writing XML then you can just pass the ® and the module will output either a raw ® or a numeric entity for it. Any XML parser that this XML gets read by should be able to cope with either, so it doesn't matter which you end up with and you don't need to worry about it.

If you use a generic templating language, then you have to deal with using a raw ® or converting it with HTML::Entities::encode_numeric() or a similar module. Basically — you have to do all the things that a proper XML module would do for you.

It sounds like you are using a generic templating language, but it is almost certainly better to use a real XML module.

Afterthought: You might also be messing about with raw strings in the middle of your code. That way lies madness.


In reply to Re^3: Convert HTML symbols to equivalent Unicode by dorward
in thread Convert HTML symbols to equivalent Unicode by jai_dgl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2024-04-23 14:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found