Closed Thread Icon

Topic awaiting preservation: Regular Expressions, strip out code [php] Pages that link to <a href="https://ozoneasylum.com/backlink?for=12904" title="Pages that link to Topic awaiting preservation: Regular Expressions, strip out code [php]" rel="nofollow" >Topic awaiting preservation: Regular Expressions, strip out code [php]\

 
Author Thread
u-neek
Bipolar (III) Inmate

From: Berlin, Germany
Insane since: Jan 2001

posted posted 09-24-2003 17:05

Hi,
let's say i have xml file containing the following informations:

code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Another Name -->
<person>
<name>Any Name</name>
<phone>65231546</phone>
<zip>64546</zip>
<mobile>634431561</mobile>
</person>


I have read the file into the variable $file.
Now i want to get the name ("Any Name") into another string. How can i do this?

Btw: it is not possible to use the XSLT functions.

Thanks.

Gweilo
Bipolar (III) Inmate

From: switzerland
Insane since: Sep 2002

posted posted 09-24-2003 17:25

preg_match("/<name>(.*)<\/name>/",$file,$matches);

This returns an array of all matches.

[This message has been edited by Gweilo (edited 09-24-2003).]

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 09-24-2003 20:19

The XSLT functions are not what you want to use for parsing XML files. You need to look at the XML parser functions.,



.:[ Never resist a perfect moment ]:.

« BackwardsOnwards »

Show Forum Drop Down Menu