File Parsing
I have a file, and I want to start searching it at a certain location, not from the begenning. I use strpos() to find a certain string in the file, and I would like to use a regular expression on the rest of the file after that point returned by strpos().
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Parsing A DBF File
I'm attempting to read and parse a DBF file that's been created by an accounting application in place. I'm wondering if anyone can point me to any resources that explain how DBF files are designed. PHP Code:
Parsing A Txt File
I would need a "script" that parses the following information in 'outdoor.txt'. What i actually need are those variables (for example $yTemp). I'd do it myself but my knowhow lacks ;D outdoor.txt is input and variables are "output" which i need to make graphs (jgraph) -------OUTDOOR.txt------- Date; Time; Temp øC 21.11.2003; 18:21:39; -2.69 24.12.2003; 23:10:45; 0.06 01.01.2004; 00:00:29; -5.75 01.01.2004; 00:43:37; -6.13 03.01.2004; 22:13:38; -8.44 05.01.2004; 07:38:58; -4.06 05.01.2004; 09:33:19; -4.50 -------OUTDOOR.txt------- i know how to read the last line and get three variables: .... $in_part = explode(";", $lastRow); $in_pvmOUT = $in_part[0]; // Date = 05.01.2004 $in_aikaOUT = $in_part[1]; // Aika = 09:33:19 $in_lampoOUT = $in_part[2]; // Temp øC = -4.50 But i don't know how to get more values at once and feed it to the array: Values should be in the following format: $yTemp = array(-2.69, 0.06, -5.78); // Average temperatures for each month $xAverage = array("Nov 2003","Dec 2003","Jan 2004"); It actually has values for every minute and every day. So how should it be done if i want to draw a graph for "today", say 5.1.2004. $yTempToday = array(-4.38, -4.44, -4.44, -4.44, -4.44, -4.44, -4.44, -4.50, -4.50, -4.50, -4.50, -4.44, -4.44, -4.50); $xTimeDecimal = array(9.40, 9.42, 9.43, 9.45, 9.47, 9.48, 9.50, 9.52, 9.54, 9.56, 9.58, 9.59, 9.61, 9.63); or $xTimeActual = array("09:23:37", "09:24:42", "09:25:46", "09:26:51", "09:27:56", "09:29:00", "09:30:05", "09:31:10", "09:32:15", "09:33:19", "09:34:24", "09:35:29", "09:36:34", "09:37:39"); -------OUTDOOR.txt------- Date; Time; Temp øC 21.11.2003; 18:21:39; -2.69 24.12.2003; 23:10:45; 0.06 01.01.2004; 00:00:29; -5.75 01.01.2004; 00:43:37; -6.13 03.01.2004; 22:13:38; -8.44 05.01.2004; 09:23:37; -4.38 05.01.2004; 09:24:42; -4.44 05.01.2004; 09:25:46; -4.44 05.01.2004; 09:26:51; -4.44 05.01.2004; 09:27:56; -4.44 05.01.2004; 09:29:00; -4.44 05.01.2004; 09:30:05; -4.44 05.01.2004; 09:31:10; -4.50 05.01.2004; 09:32:15; -4.50 05.01.2004; 09:33:19; -4.50 05.01.2004; 09:34:24; -4.50 05.01.2004; 09:35:29; -4.44 05.01.2004; 09:36:34; -4.44 05.01.2004; 09:37:39; -4.50 -------OUTDOOR.txt-------
Parsing A .doc File
is there a way to get the contents from a .doc file that's readable im using get_file_contents but it's coming out very weird: $filename = $renamed_cv; $content = file_get_contents("cvs/$filename"); $cv_for_mysql = mysql_real_escape_string($content);
Parsing A Big Xml File Gives Seg Error
Hi, I'm parsing a *very* big xml file (600MB+) in order to do multiple inserts into a mysql table, but after about 80,000 inserts (5 minutes) I get a seg fault and obviously the script stops. I'm expecting it to get up to around 1 million rows. The method I'm employing to read the file in follows and then one of my xml_element handlers does the insert, which i didn't bother showing for the sake of brevity. <? # snipped code function grab_file($parser,$file) { #<snip> while($data = fread($handle, 4096)) { xml_parse($parser, $data, feof($handle)); } #<snip> } $parser = xml_parser_create(); xml_set_element_handler($parser, "start_xml_element", "stop_xml_element"); xml_set_character_data_handler($parser, "character_xml_data"); xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); grab_file($parser, $file); xml_parser_free($parser); ?> The script itself seems to be working fine as I tested it with much smaller data set and it went like a breeze, so I'm assuming this is coming down to system resources. Under normal load the box has about 20MB of free memory (64MB max) and about 300MB swap space (400MB+ max). Just before my seg fault, free mem had fallen to less than 1MB and swap space was down to 200MB, the 'size' of the script in ps view was 200MB+ So, when I'm reading this file in, does php not just buffer the 4KB that it's useing for that particular loop? and throw it away when finished? This doesn't seem to be the case, but I'm confused as to how the script can be taking up 200MB, possibly the xml parsing functions are buffering the whole thing? In short, how can I keep memory useage down (by a large factor)?
File Data Parsing In PHP
Could someone show me how to parse data in a text file using PHP and store the data in variables and MySQL? We have text files that contain information that looks something like this: EXAMPLE : Elephant OBJECT : Animal LOCATION : South Africa LOCATION : America EXAMPLE : Water Lily OBJECT : Plant LOCATION : Manila EXAMPLE : Panda OBJECT : Animal LOCATION : China … and so on… How can I manipulate the data inside a file? The data should be stored in a MySQL tables considering the relationship of every data element.
Parsing Stats File
Right now, I have a bunch of stats files from the NHL that are in the format of: "TYLER ARNASON CHI 3 1 1 2 0 0 0 0 1 0 11 9.1" Those aren't tabs, they are just a bunch of single spaces. Now, I want to be able to either a) replace the spaces between each field (not between the first and last name) or b) break each field value down into a variable. Any ideas or tips?
Parsing A Dynamic RSS File
I'm a bit new to PHP, so please bare with me. I've been studying it for a couple of months now and really like it. On the main page of my website, I would like to include a small box that lists the title of the latest blog entry (as well as making that a link to the entry) to my WordPress blog. I was thinking about parsing the RSS for this, but I'm not sure how to parse a dynamic RSS feed. Or is there some simpler way of doing it and I'm trying to overprogram?
Parsing .htaccess File
I want to parse the contents of an .htaccess file from within PHP. The contents of the .htaccess file looks like this: <Files foobar.tar.gz> AuthType Basic AuthUserFile /foobar AuthName "Foobar" <Limit GET> Require user FOOBAR </Limit> </Files> And so on. When I read in that file with the following code: $fd = fopen(".htaccess", 'rb'); while (!feof($fd)) { $line = fgets($fd, 1024); echo "|".$line."| "; } fclose($fd); Then I get empty lines for those lines containing <Files ...>, <Limit ...> and so on. How can I get at those lines as well? What I need to know is basically the information "which user can access which file?"
Include File Without Parsing It
On my server, what I am planning on doing is having users be able to upload their own HTML files, image files etc etc -- and then... (long story short) be able to have my own self-contained "virtual" web hosting, where the users get a certain amount of space to use. Their files would therefore be uploaded like regular files, right onto the filesystem; this is fine, except I don't want these users to have access to PHP in their files (which comes inevitably if they have their files on the filesystem). My web host has it enabled to where .html files are processed in PHP (I have to have it this way anyway, because my whole site is using PHP with .html extensions). My solution to restricting my users files from having access to PHP is by using tricky .htaccess and Not Found pages -- to when a request comes up for URL for example, it will call my Not Found script. The Not Found page will locate the user's file (which is located in a separate folder) and transparently "include()" the requested file, not parsed by PHP. So, inevitably it comes to this: is there some way that I can use some tricky functions (preferrably string functions, they're quicker, but if all else fails: regular expressions) to scan the requested user file before it is outputted and remove all <? and <?php and <SCRIPT LANGUAGE="php"> in the file.
Parsing XML File Out Of Memory?
What I'm doing is the following: - Load XML data a file - Parsing the XML data - Printing some parsed content The problem is that the script execution is stopping before all the content is parsed and printed. Maybe the PHP is out of memory after a while. That would make sense since the XML file is about 2 MB.
Parsing Text File
I'm working with a text file that contains the names of websites and their corresponding URLs in the following fashion: <a href="www.cnn.com">CNN News</a> Each site and title is separated by line breaks. I'm not very experienced with fopen, fread, etc. and was wondering if anyone could give me pointers on how to go about reading the text file line by line and saving the URL and title in separate columns in a database. Oh, and one more thing. The categories of these sites are also included every so often. I was hoping to save the category in a third field. Ex: News ( new line here) <a href="www.cnn.com">CNN News</a> () <a href="www.bbc.com">BBC News </a> etc.
Parsing An XML File Into A Table
I'm trying to parse an xml file into a table on a webpage. I'm using php5 which, I believe, doesn't support xsltproc anymore (since xml support was rewritten for php5). I have got it working on my home server using xsltproc and an xsl file on the command line (unix) but I want to transfer it to a host which doesn't have xsltproc installed and have the xml file parsed into a table by php because I know it can be done. The actual page that I'm trying to parse is here Can anyone give me any pointers/links/howtos for parsing xml files into a table using php?
Parsing XML Feed Without File Functions
I've written a php script to parse a remote XML file. This works fine on my test server however, the chap I've written the script for is using a hosting service which has disabled the file functions. Is there any way of parsing the xml file without access to the File or Curl functions? Script is below: if (!($fp=@fopen("http://server/xmlfeed.xml", "r"))) die ("Couldn't open XML."); $count=0; $element=array(); $state='' function startElementHandler ($parser,$name,$attrib){ global $count; global $element; global $state; switch ($name) { case $name=="SELECTION" : { $element[$count]["child1"] = $attrib["child1"]; $element[$count]["child2"] = $attrib["child2"]; $element[$count]["child3"] = $attrib["child3"]; $element[$count]["child4"] = $attrib["child4"]; $element[$count]["child5"] = $attrib["child5"]; break; } default : {$state=$name;break;} } } function endElementHandler ($parser,$name){ global $count; global $element; if($name=="SELECTION") {$count++;} } function characterDataHandler ($parser, $data) { global $count; global $element; } if (!($xml_parser = xml_parser_create())) die("Couldn't create parser."); xml_set_element_handler( $xml_parser, "startElementHandler", "endElementHandler"); xml_set_character_data_handler( $xml_parser, "characterDataHandler"); while( $data = fread($fp, 4096)){ if(!xml_parse($xml_parser, $data, feof($fp))) { break;} } xml_parser_free($xml_parser);
Encoding Problem - Parsing An Xml File
I have a problem while parsing an xml file. The file is a backup from moodle (moodle.xml). When i open the file with one of my editors and setting Encoding to utf8 font courier standard or greek characters the editor can see all greek strings contained within the file perfectly. On the other hand when i try to open it with php parse it and then display it on a web page the data from the file come out like latin characters like (A~ atilde)(o: o umplaud) and others like this. Updating moodle is not an option so i have to find a workaround. Has anybody heard of something like this?
Parsing CSV-file And Adding CSS To Style
I'm parsing a CSV-file into a table on a webpage - and I'd like to be able to change the alignment for the _last_ <td> in each <tr> - but, as the file is today, it's not possible for me to assign a CSS-class on only the last <td>. I was wondering if anyone could give me a clue as to what I need to change in the following code, to make this possible (I'm assuming I need to have each <td> present in the code, so as to be able to assign a class to the last one, but how? I can tell as much as that I know the number of <td>'s in each CSV-file - they are a constant). Here is the code: <?php class csv{ /* This class builds a html table from the contents of a CSV file. */ var $html = '' function csv($csvFile){ if(!$csvHandle = fopen($csvFile, 'r')){ $this->html .= "Couldn't open $csvFile."; } else{ $this->html .= "<table id="dusjkabinetter"> <thead><tr> <th id="th2" valign="top" align="left">Prod. nr:</th> <th id="th3" valign="top" align="left">Bilder:<br />(klikk for større visning):</th> <th id="th4" valign="top" align="left">Beskrivelse:</th> <th id="th5" valign="top" align="left">Pris:</th> </tr> </thead> "; while(($row = fgetcsv($csvHandle, filesize($csvFile))) !== false){ $this->html .= "<tr>"; foreach($row as $field){ $this->html .= "<td>$field</td>"; } $this->html .= "</tr> "; } fclose($csvHandle); $this->html .= "</table> "; } } function getHtml(){ return $this->html; } } echo <<<TABELL_START <div class='t_tabell'> TABELL_START; $html .= "<h2>Dusjkabinetter</h2> "; $mycsv = new csv('csv-filer/dusjkabinetter.csv', ' '); $html .= $mycsv->getHtml(); echo $html; echo <<<TABELL_SLUTT </div> TABELL_SLUTT; ?>
Skip First Line When Parsing An Xml File
I have an xml file which I cant change, the problem is that the first line looks like this <?xml version="1.0" ?> with the rest of the xml being fine. However when I try to parse this I am getting a malformed xml error. THis line was added recently, the parser worked before. My question is how can I get rid of this first line in the xml file - which I get from an internet feed using fopen("http://dsfsf.com/sdf.xml", r);
Parsing An Mbox File Without Imap?
I have an mbox mailbox on a linux server that I need to open and parse, message by message, looking for content via PHP. However, for whatever reason, my hosting provider has not compiled PHP with IMAP support. Does anyone have anything written that I can download and use (free would be nice, heh) to parse my mailbox looking for keywords and delete/expunge/forward/autoreply based on what I find? Doesn't need to be super fast for processing speed as I'm the only one using it and wil only run it once or twice per day on a few MB of Email. I just don't want to reinvent the wheel if someone out there has what I'm looking for.
Parsing Out A File Using Special Characters
I am creating a site where someone would enter data into a few text boxes, with the potential for them to be fairly long. I am therefore saving them into a text file instead of a database. With these, there is a potential for someone to use the enter key in these boxes, therefore making it very difficult to just parse it out by line. I am currently trying to figure out how to parse it by special characters (or groups of characters such as "%%$$%%" or something that noone would ever type, on purpose or by accident) I was wondering if there was a way to parse this out by these special characters, or if there was a way to save those line returns that the people enter as something other than a line return.
Accessing CSV File For PHP Parsing From Remote Server
What function can I use to grab a .csv file from a remote webserver for use in my PHP script. I want to do some parsing and statistical analysis on it (server side). What PHP function is used for this? I can't seem to find it in Google or the online PHP manual, because I don't really know what keywords to use.
.htaccess - Parsing A PHP File With A .html Extension?
Can I use .htaccess to parse a PHP file with a standard .html extension?? This doesn't seem to work: AddType text/html .html AddHandler server-parsed .html I'm using a remote host, so modifying the server's .conf file isn't really an option nor is modifying the php.ini file.
Parsing Ascii File Into Multi Dim. Array
I am trying to load a txt file into a multidimensional array. Eech line in the txt file has 3 fields, delimited by a | i.e. field1|field2|field3 field1|field2|field3 ... This is the code I have right now that adds each line to an array PHP Code:
Domxml - Parsing An Xml File Once Per Session Rather Than Every Time
I am working on an embedded system. The entire configuration for the system is stored in an XML file, which is pretty long. It takes about 3 seconds to open the file using domxml_open_file. Breaking the file into smaller files is not possible; a single XML file is a part of the design requirement. Right now we're opening and freeing the file every time any data is requested from the file, which is quite often. This means that the user ends up waiting about 5 seconds total before the page is generated. It would be nice if we could open the file once per session, and keep the file open throughout the session, rereading only when the file on disk changes.
Parsing A RSS Feed And Generating A Static .html File With PHP
I have this small project for my site, if you can't point me to some resources or help me out I'll thank you very much. The homepage of my site points to the different services I offer (chats, forums, my blog and a podcast for spanish speakers). I want to make this homepage more dynamic, but since the homepage gets more than 10000 daily unique visitors I don't wanna make it a .php file ('cause my hosting provider might get mad with the server's resources). So what I need is to program a php script that I would run on-demand (probably 1 or 2 times a day) and that would make this: - Parse the RSS feed of my blogs and the forums - Generate a static .html file (the homepage) with the normal content plus the headlines from the feeds. That way everytime I update my blogs I could run that php script to re-generate the homepage, with the updated info from the feeds. Any help, suggestions, comments, links on how to do this will be very helpful. I'm not very experienced with PHP (I come from J2EE development), but I'm armed with 2 PHP books as a reference.
Parsing .inc As .php
how do I parse .inc as .php files? Is it that useful to do this? Is it so unsafe to include() them otherwise? On my Linux box, I've got both httpd and httpd2.conf (don't ask me, it was auto-configured that way). I think both files are useful, but in which of these do I insert whatever you're going to give me?
URL Parsing.
I have come up with a couple ideas, but I would like some input on the most effective way to parse a URL from the body of a mail message. I have a small script which accesses mail for an account and retrieves the message body(imap_body). I want to parse through the body and pull out URL's, anyone have some good advice on a practicle method?
Parsing XML,RSS Through PHP
Do anybody know 'bout parsing RSS through XML (PHP). I wanna learn RSS, but before that i must know XML. It would be helpful if anybody guide me in the right direction from where to take start learning XML (link, url). And after having the elementary knowledge 'bout XML i would be able to parse RSS.
Parsing XML
I'm trying to figure out how to parse very simple XML files using PHP 4.3. I have been unsuccessful at finding simple explanations of how to do this. I found the following code somewhere (can't remember where) and it works great EXCEPT it does not keep my CSS class tags. The result is that everything shows up as a <p> rather than <p class="text">, etc. How do I modify this code to allow this? Or is there a better way to accomplish this? <?php $file = "myfile.xml"; $map_array = array( "bold" => "b", "emphasis" => "i", "literal" => "tt" ); function startElement($parser, $name, $attrs) { global $map_array; if (isset($map_array[$name])) { echo "<$map_array[$name]>"; } } function endElement($parser, $name) { global $map_array; if (isset($map_array[$name])) { echo "</$map_array[$name]>"; } } function characterData($parser, $data) { echo $data; } $xml_parser = xml_parser_create(); // use case-folding so we are sure to find the tag in $map_array xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, true); xml_set_element_handler($xml_parser, "startElement", "endElement"); xml_set_character_data_handler($xml_parser, "characterData"); if (!($fp = fopen($file, "r"))) { die("could not open XML input"); } while ($data = fread($fp, 4096)) { if (!xml_parse($xml_parser, $data, feof($fp))) { die(sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser))); } } xml_parser_free($xml_parser); ?>
Parsing An URL
I want a PHP script that will for example split http://example.com/dir/index.htm into http://example.com/dir and index.htm It also needs to split up an URL with GET variables at the end. eg http://example.com/dir/link.php?id=123&no=abc Any help would be appreciated...
Parsing XML
I have some problems with parsing this sample xml file. <section id="L11"> <group id="L21"> <field key="name1" value="1"/> <field key="name2" value="2"/> <field key="name3" value="3"/> <field key="name4" value="4"/> <field key="name5" value="5"/> <field key="name6" value="6"/> </group> <group id="L22"> <field key="name7" value="7"/> <field key="name8" value="8"/> <field key="nam9" value="9"/> </group> </section> <section id="L12"> <group id="L23"> <field key="name10" value="10"/> <field key="name11" value="11"/> </group> <group id="L24"> <field key="name12" value="12"/> <field key="name13" value="13"/> <field key="nam14" value="14"/> </group> </section> PHP Code:
Xml Parsing With Php
I use PHP (and PHP socket functions) to exchange very short XML documents between two Flash clients like this: <MESSAGE id="myid" text="mytext" /> I don't parse the XML document within PHP but send back the XML document made by the Flash client to another Flash client with a php socket and Flash parse it with its own XML parser ... In order to detect errors or non-XML data I do like this (in php): switch (true){ case ( ereg("<", trim($XMLdata)) ): print 'xmldata' break; default: print 'no xmldata' } (I must do this because Flash sends an empty "heartbeat" every 5 seconds, which is not XML data) Now, I need to interpret my XML document inside php cause I want to make php execute some commands when it receives a certain type of XML element. XML data that can be sent from Flash : <MESSAGE id="myid" text="mytext" /> or <COMMAND1 /> or <COMMAND2 /> or or an empty string "" . (in php) I can do : switch (true){ case ( ereg("<MESSAGE", trim($XMLdata)) ): print 'xmldata is a txt message' break; case ( ereg("<COMMAND1", trim($XMLdata)) ): print 'xmldata is a command1' break; case ( ereg("<COMMAND2", trim($XMLdata)) ): print 'xmldata is a command2' break; default: print 'no xmldata' } But what I'm wondering is whether it is the good way to proceed, wouldn't it be faster to parse the xml document within php with Expat library included when it receives a document "<COMMAND idcom="1" />" and interpret "idcom" value instead of doing an "ereg("<COMMAND1", trim($XMLdata))?
XML Parsing!
I've looked and searched and tried to find information about how to solbve this problem, but I can't. I'm beginning to think that I should start from scratch to do it right. I am trying to parse the data from the weather channel in PHP. A slice of the data looks like this: <weather ver="2.0"> <cc> <lsup>3/4/05 8:50 AM Local Time</lsup> <obst>Vasteras, Sweden</obst> <tmp>-7</tmp> <flik>-12</flik> <t>Mostly Cloudy</t> <icon>28</icon> <bar> <r>1,010.8</r> <d>steady</d> </bar> <wind> <s>10</s> <gust>N/A</gust> <d>180</d> <t>S</t> </wind> <hmid>83</hmid> <vis>10.0</vis> <uv> <i>0</i> <t>Low</t> </uv> <dewp>-9</dewp> <moon> <icon>22</icon> <t>Waning Half, Last Quarter</t> </moon> </cc> </weather>.......
Looking For Help With RSS Parsing
I'm working on a script to work with podcast feeds (RSS) and have found the lasRSS parser to be quite good. http://lastrss.webdot.cz/ I've modified this to work with i-tunes tags (as they have added their own to the RSS vocabulary!) however I still have one set of tags - category - that I am stuck with. an example of these tags (Category Technology, Sub Category Computers) would be: <ITUNES:CATEGORY TEXT="Technology"> <ITUNES:CATEGORY TEXT="Computers"></ITUNES:CATEGORY> </ITUNES:CATEGORY>
Parsing XML?
I have a slight problem with parsing XML: If the tag was say - <Something ID="12"> - My parser is only retrieving the 'Something' part, and discarding the 'ID="12"'. Code: function startElement($xml_parser, $name, $attrs) { echo $name; //this is the part with the issue } function endElementStuff($xml_parser, $name) { } function charData($xml_parser, $data) { echo $data; } $xml_parser = xml_parser_create(); $ml_set_element_handler($xml_parser, "startElement", "endElementStuff"); xml_set_character_data_handler($xml_parser, "charData"); xml_parse($xml_parser, $result, TRUE); xml_parser_free($xml_parser);
Parsing Xml
I am trying to parse a very large rdf file, 585 MB to be exact. It's content.rdf.u8, dump file from the open source directory: www.dmoz.com/rdf I have parse the smaller version (30K) of the file, but no luck with big one. If anyone has parsed this file or knows how to parse this type of file.
Xml Parsing
i am trying to read an xml file using php and i am stuck at a place, below are my xml tags, i have to retrieve the attributes of the parent and the corresponding tags Code:
Xml Parsing
I've spent many hours trying to understand why the dom-functions in php do this and that, but the following I can't understand: My xml-file looks like: <Data> <Article> <Number>3746</Number> <Description>This is the article description</Description> <Groups> <Group1>Group1</Group1> <Group2>Group2</Group2> <Group3>Group3</Group3> </Groups> </Article> </Data> having the current node "Groups", I call //-- snip $childNodes = $curNode->child_nodes(); echo "Number of child-nodes: " . count($childNodes) . "<br>"; //-- /snip The output is: "Number of child-nodes: 7" When I echo the node_name() of each child-node, every second node is called #text Could anyone of you explain why php reacts like this? I would expect a child-count of three and definitely no #text-nodes...
RDF Parsing
I'm looking for an easy to use and understand RDF parser for PHP. Preferably lightweight if possible. I'm currently trying to get my head around this one.: http://www.wiwiss.fu-berlin.de/suhl/bizer/rdfapi/ are there any others that might be considered to be better quality or easier to use?
Parsing An XML (same TAG Name)
I am stuck processing an XML file. The problem I am having, is I have the same TAG name - Url - at the same depth, so the value from the last Url read in is what get saved. I have tried every option I can think of to put each URL tag into its own variable, without any luck. I removed portions of the code that does not affect the outcome (for a smaller post). Here's a snippet of the XML, and when the code (below) runs, no matter what, the value of $items[$itemcount]['url'] is always /TiVoVideoDetails?id=465887. - <CustomIcon> <Url>urn:tivo:image:save-until-i-delete-recording</Url> <ContentType>image/*</ContentType> <AcceptsParams>No</AcceptsParams> </CustomIcon> - <TiVoVideoDetails> <Url>/TiVoVideoDetails?id=465887</Url> <ContentType>text/xml</ContentType> <AcceptsParams>No</AcceptsParams> </TiVoVideoDetails> PHP code: <?php class Tivo_XML { var $dvr; function parseTiVoXML() { global $items; $this->parser = xml_parser_create(); xml_set_object($this->parser, &$this); xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, false); xml_set_element_handler($this->parser, "_tivostart_element", "_tivoend_element"); xml_set_character_data_handler($this->parser, "_tivodata"); $file = $this->dvr . "_nowplaying.xml"; $tivoxmlstr = file_get_contents ($file); $tivoxmlstr = str_replace("&", "%amp;%", $tivoxmlstr); xml_parse($this->parser, $tivoxmlstr , true) or die (sprintf("XML Error: %s at line %d", xml_error_string(xml_get_error_code($this->parser)), xml_get_current_line_number($this->parser))); xml_parser_free($this->parser); return $items; }
XML Parsing
I have been trying to wrap my head arouns this, but I can't seem to get it to work the way I want it to. Could someone helpful please tell me how I get this: <function> <name>array_push</name> <examples> <example> <name>A way to do it</name> <code> $array = array("foo", "bar") $array = array_push($array, "goo") </code> </example> </examples> </function> To this: array ( name -> array_push examples -> array( example -> array( name -> A way to do it code -> $array = array("foo", "bar") $array = array_push($array, "goo") ) ) ) My problems so far has been traversing the xml in a good way and: 1. After parsing, I am left with the code stripped of variables '$array = array("foo", "bar")' becomes ' = array("foo", "bar")' 2. Newlines in the code disappaers, how do I make them stay? Anyone feeling overly helpful and could give me an example to make the above xml into the above array.
How To See Without Parsing
I am trying to learn some php and sometimes i want to see how other people do it. My question is: is there a way for me to view the original unparsed file and not the result? If i simply click on it i see the reulting html. I want to see the source.
PHP 4.0.6 And XML Parsing
I wrote an XML parsing class, and the day that my host upgraded to PHP 4.0.6, my script quit working. At first, I thought XML parsing in general was hosed, but I used a quick XML parsing script and it worked fine. I think I found the issue. Here's what my class looks like: PHP Code:
XML PARSING
I am working on a project where I am parsing an xml document. The document is converted from a rich text microsoft word document. I'm using this standard parsing method: $xml_parser = xml_parser_create( $type ); xml_set_element_handler($xml_parser, "start_element", "end_element"); xml_set_character_data_handler($xml_parser, "character_data"); When I run the script using this Method, the text will randomly cutt off before the xml string has been parsed.
Parsing XML With PHP - Not DOM XML
I am not really sure how to parse files with PHP XML other than DOM XML. Unfortunetely, I have run into a few problems with size and was told that for the type of parsing I am doing I would be better using event driven parsing like SAX. Below I have a simple example of XML similar (although much much smaller) to the one I am using for real. XML: <?xml... <root> <name age="25">Martyn</name> <name age="24">Neil</name> <name age="24">Robbie</name> </root> All I want to do is to output them as: Martyn (25) Neil (24) Robbie (24) How would I do this uisng something like SAX / EXPAT? I found tutorials but didnt really understand them enough to know if I was looking up the correct thing.
XML Parsing - Help!
I've been following this tutorial and can get it working, but what i want to do is take the data from a dynamic aspx xml file $xml_file = "http://www.example.com/xml/Search.aspx?make=Ford&model=Accord"; i have downloaded the source of this aspx file and saved it as an xml and I can get it to work. the error I get when trying to parse the dynamic xml is "Could not read file" this tells me so far that it has successfully read this file using 'fopen' but it cannot read it using 'fread' can anyone shine some light on me on how to successfully parse an aspx xml feed with php? is it something to do with the values in the url?
Parsing
in a php script i'm writing, i want to set $email=fire_juggler_03@hotmail.com.nospam but it doesn't like it. How should i write the underscores? because i know you have to ' for apostrophes.
Parsing
What i am trying to do is parse some information from a site (easy enough) however i need to be loged in to the site to get that information and i have no idea how to do that. Could someone give me an example please? http://sigil.outwar.com login_username=username login_password=password Once loged in i then need to go to another page which can just be linked to once loged in.
RSS Parsing
I`m making a website that will parse rss from blogs. First i used magpierss but it did`t satisfy me because of those annoyng charsets. Anyway, right now i`m using another parser. This is my concern: How to parse all the data from rss including categories and subcategories from blogs. I mean, how to insert in database the categories and subcategories and how to query them? I made the categories and subcategories table in mysql, but how to insert from rss to mysql? When i enter a rss feed to parse, it grabs it all.
Parsing Xml
I want to be able to search xml document (using it as a db) and display the results out of it. i've done that in aspx before, and have the code for it. i am new to php and want some help in this regard. my xml document looks like this: Code:
|