Problem with parsing an XML file

Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default Problem with parsing an XML file

    I'm writing a php program to convert a XML file into html. The XML file is
    like a bookmarks, or address list.

    The XML file looks something like:
    <entry>
    <aname>George Dummy</aname>
    <aurl>http://www.georgedummy.net</aurt>
    </entry>
    <entry>
    <aname>Fred & Wilma Flintstone</aname>
    <aurl>http://fredflintstone.com</aurl>
    </entry>

    etc.

    Now, the problem I'm having is with the '&' in the name. At first, I had
    problems with xml_parse simply returning 'false' and not parsing the rest
    of the file. After some playing around with htmlentities and the
    translation table, I've managed to get xml_parse to succeed and continue
    parsing. But, instead of getting:

    "Fred & Wilma Flintstone"

    in the output, I get

    " Wilma Flintstone"

    That's not what I want. Optimally, I want to have:

    "Fred &amp; Wilma Fintstone"

    in both the input and output files. That way, if I need to use other
    entities, like &eacute; I can put them in the input file in the appropriate
    place, and have them come out in the output file as well.

    As I said, I can get all entities to work, *except* '&amp;'

    At one point, I thought I was having problems with the arg_separator.input
    or arg_separator.output variables, but I used ini_set to set both of these
    to null and I still have problems.

    Anybody have any idea what the problem is and how to fix it?

    I'm running PHP on a Unix system, Redhat 7.1. The version of PHP is php
    4.3.2.
    Mr. French Guest

  2. Similar Questions and Discussions

    1. Parsing a .PDF file Question
      I have been trying to parse a .PDF file with a PERL program (I'm a REAL newbie, today is my first session with "Perl for Dummies" ) but I'm unable...
    2. Parsing fields in a log file
      I want to parse a web log file that starts with the following lines: #Software: Microsoft Internet Information Services 6.0 #Version: 1.0 #Date:...
    3. HTML File Parsing
      hi, like xml dom and xmlreader used for working with xml files. how can i do this with html files. i want find all the hyperlink tags <a>...
    4. Parsing a local file
      I am trying to build script that will parse a file on the user's computer. There are 2 things that I am not quite sure about. 1) How to read a...
    5. Help with parsing text file
      All, I'm trying to parse a text file with logic that essentially goes like this: 1) open the file for reading with a handle 2) match for a regex...
  3. #2

    Default Re: Problem with parsing an XML file

    try :

    $newstring = htmlentities(string from user input);
    Chris Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139