Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Most Efficient XML Parser For PHP


I was trying to get the answer on the net but I only found partial answers -
I hope someone can help me out...

I am looking for an XML parser that would:

1) validate XML before doing anything
2) be fast
3) allow parsing of big XML documents (small memory footprint)

I am implementing a system that will fetch XMLs from multiple sites across...




View Complete Forum Thread with Replies

Related Forum Messages:
Which Is More Efficient PHP Or SSI
I'm building this website and there are four parts of the site I want to be the same on every page (header, footer, menubar, news section). Now I'm about to expand this site from a couple of pages to 50-60 (currently static) pages and I don't want to have to change all of those pages for example every time I change a link in my menubar.

Now I know I can do this with Server Side Includes but I'm also hearing I can do this with php. My question is which is more efficient. Efficiency being measured by speed and how much processing power it will take up on my server. I don't want to change my html pages to .shtml or .php and I've been doing research and I'm hearing that SSI's will eat up my servers CPU when doing this because my server will have to parse every .html file. Does anyone know if that's the case and wouldn't that be the case if I used php as well.

Also if I could just get some general feedback on what you would use in this situation I'd be very grateful. I'm somewhat new to both and I need a direction to go in so I can plan out my site.

View Replies !
Is There A More Efficient Way To Do This?
I'm using PHP 4.3. I have 15 pages in which I need to take the
content of the BODY and put it in a little table ...

<table>
<tr><td colspan="3"><img src="header.gif"></td></tr>
<tr>
<td><img src="left_img.gif"></td>
<td><!-- body content goes here --></td>
<td><img src="right_img.gif"></td>
</tr>
<tr><td colspan="3"><img src="bottom.gif"></td></tr>
</table>

It is a pain to have to cut and paste all this HTML code (the above is
just an abbreviated version) into all 15 pages. And plus, if the shell
changes, I'll have to change it in 15 pages.

View Replies !
More Efficient
On a picturepage up to 25 pictures can be displayed and I want to store filesize and length/width of the pictures in a table. So what is more efficient? Have 25 fields for filesize + 25 fields for length/width = 50 fields per row. Store everthing as an "array" in a textfield ie. 100KB-1024x800:120KB-800x640.

View Replies !
Most Efficient Forum DB
What would be the most efficient way of storing the posts in a forum?

If I store them in the DB with a massive char string, it seems a little bit rediculous. Especially since the size range is huge. Would it make sense to save each post as its own file and read each post to the browser? What is the standard for doing this?

View Replies !
More Efficient Coding
Is there any way I could shorten this code? If I want one variable from a table in my database, I do this: PHP Code:

$blah=mysql_query("Select * from users where username='".$_SESSION['username']."'");
$row=mysql_fetch_array($blah);
$city=$row["city"];

View Replies !
A More Efficient Selection
I'm using the following code by which users pick up a name from a field in a table. It worked well for a fair bit but now my table has about 2500 odd names and its getting tedious scrolling thru the list. Can anyone suggest a more efficient way to go about it ? maybe a user typing the first 3 letters of a name or some such ? PHP Code:

Customer</td><td><select name="customer"><option value="">[Select One]
      <?php

mysql_connect("localhost", $dbname, $dbpasswd )
        or die ("Unable to connect to server.");

mysql_select_db($database)
        or die ("Unable to select database.");

$result = mysql_query("SELECT DISTINCT `Company` FROM `Customers` ORDER BY `Company` asc ");
.........................................

View Replies !
Cron Being Efficient
PHP Code:

$cron_sql = mysql_query("SELECT oid, uid, amount FROM type") or die(mysql_error());
        while($user = mysql_fetch_array($cron_sql)){
                $amount_tt = (($user["amount"] * 35) + 2500);
                $uid = $user["uid"];
                $amount_sql = mysql_query("UPDATE statistics SET total=total+$amount_tt WHERE uid='$uid' LIMIT 1") or die(mysql_error());         }

View Replies !
Efficient Solutions For Pagination?
Anyone have an efficient solutions for pagination? I have to display a number of items but would like to paginate using only 10 lines of data on each page and provide navigation at bottom.

View Replies !
Efficient Uniqueness Check
I have affiliates submitting batches of anywhere from 10 to several
hundred orders. Each order in the batch must include an order ID,
originated by the affiliate, which must be unique across all orders in
all batches ever submitted by that affiliate. I'm trying to figure out
the most efficient way to check the uniqueness of the order ID.

Order data is being submitted to Zen Cart, and also stored in custom
tables. I have created a unique key in the custom tables, consisting of
affiliate ID and order ID, but that's not workable because the custom
tables need data from ZC, and I don't really want to submit the data to
ZC until I've checked the order IDs, plus part of the batch might already
be stored before I hit a dup, and would then have to be deleted.

There are currently about a half dozen affiliates; I have no idea how
many there will be ultimately. The client I'm developing this for thinks
1-200. Each affiliate can potentially have several thousand order IDs
that need to be checked.

The two ways I'm considering are: 1) a single query to load all the
affiliate's order IDs into an array for checking as I process the batch;
2) creating a temporary table with just the affiliate's IDs, querying it
for each order in the batch.

Any ideas which would be more efficient? Would there be any significant
difference either way?

View Replies !
The Most Efficient Encryption Method?
many site use encrypted resource ID, rather than plain
numeric ID, such as the following:

Quote:

View Replies !
PHP Load + Efficient Programming
I have a question about INCLUDING files.  For example, let's say this file is
FOOBAR.PHP:

<?php

class bar {
function here..   //There are 10000 lines of code in this class
function here.
}
foo = new bar(); ?>

OK, so I have this FOOBAR.PHP I include.  Let's say I don't even USE every function in foobar.php....I only use it for a couple functions, which total like 100 lines. Does that slow down my entire script if I include the whole file (because the PHP interpreter runs through 10000 lines of code?).

View Replies !
Efficient Way Of Appending To An Array?
anybody know an efficient way of appending to an array?

$array[]='test';
$array[]='test';
$array[]='test';
$array[]='test6';
$array[]='test';

say... i want to move test6 to the #2 position... and increase the other keys under it... by 1...? i know i could make a function to do this... just didnt know if php had a built in function like that :-)

View Replies !
More Efficient Code For Validation
I want to prevent the end user from keying in particular keywords when they query my database. I using the code below which works fine.

I want to simplify this code using some sort of wildcard search. I specifically want to prevent people from keying in the following keywords: Code:

View Replies !
Efficient Connection To MySQL
Now, i'm using 6 or 7 queries in a page with ajax. In Addition to that, i open
connection to mysql for every query. I think it isn't efficient way. However, when i open only one connection to use for every query, php interpreter gives error. What should i do for efficent use of connecting to mysql?

View Replies !
Mysql Make Efficient
I have database what stores code changes I have the following code for handling the output but its acting weird and I wonder if its the way I'm coding it: Code:

View Replies !
Most Efficient Way To Validate Form Elements
What is the quickest or most efficient way to validate form elements, mainly e-mail addresses?

View Replies !
Efficient Session Re-register Code
What I have going is working, but I wonder if there's an easier way to do this. I tried using an associative array but had some problems.

View Replies !
More Efficient MySQL Data Retrieval
To store all of my traffic information, my site keeps two sets of files. One called the "counter" that simply records the IP address of the client from the current page view in a file that is named with the current date, and the other called the "tracker" which records information about every single page view sent by the client (including IP address, page accessed, referer, etc).

So far, this has worked well. To find the number of page impressions, I have the program count the number of IP addresses in the counter file. To find the number of visitors, I go by unique IP addresses.

I've decided that I would like more functionality, like being able to pull up certain dates, display graphics showing traffic trends, etc.. so I've converted all of my flatfiles to MySQL. The new database currently has over 100,000 records, and will grow by one record for each page view of the site. With this method, I can now create about any script that gives me the information that I want.

Unfortunately, a simply lookup seems to take longer than I'd want it to. For instance, if I want to know the number of impressions for today, I would use this query:

SELECT * FROM Table WHERE Date = '$Date'

This takes about one second, which I can live with (can't use COUNT(), you'll see why in a minute, but performance-wise it doesn't seem to matter anyway). But if I want to know the number of impressions from $StartDate through $EndDate broken out by day, I have to make multiple queries, one for each day. So if I wanted to find the amount of traffic from day 1 through day 30 of a given month, it would take about 30 seconds to retrieve this data. It would also take about that amount of time to retrieve this data to display a graph showing traffic trends throughout the month.. and it would take a considerably longer period of time to generate a graph that would show traffic over a year or more. Then it gets more interesting when you find out that I have to compare each record's user agent to make sure that it's a real visitor (I don't count bots in my traffic).

Is this normal, or is there some magic query that I'm not thinking of? It doesn't seem that the number of records returned has anything to do with it, because I used Date and Time to narrow my search down to a single record, and the return time 1.10 seconds.

View Replies !
Efficient Intense Image Resizing
I've heard that resizing images through PHP (either GD2 or ImageMagick)
is a processor intensive exercise. I'm setting up a site where users
will be uploading up to 10 images along with the details of their
product. For each image uploaded (max 500Kb), I'll be resizing it to
create a small, medium and large version after which I'll discard the
original. My worry is that as the site becomes more popular, the
processor time spent resizing images could badly effect the other areas
of the site (viewing/searching products).

Has anyone got any experience implementing a very high traffic site
where images are uploaded and resized? Any advice?

I saw somewhere on usenet a comment that using exec() to launch
ImageMagick to resize was quicker than using the PHP GD2 or ImageMagick
API, anyone had any experience of this? I would have though that either
way, the Apache thread dealing with the PHP script still has to wait
until the function call or the call to exec() has finished or is this
not the case? Does the exec() call run synchronously? Is there a
similar function which does run synchronously?

Finally, has anyone had any experience storing images in a MySQL DB
against storing in the standard file system? Much difference in
performance?

View Replies !
Making Mysql_connect More Efficient In My Script
I'm working on some scripts someone else made, and it's littered with
repetitive mysql_connect's and mysql_select_db's.
For example:
// MAKE SURE IT IS A VALID PRODUCT
$connection2 = mysql_connect("localhost", "root") or die ("Couldn't
connect to the server.");
$db2 = mysql_select_db("priceretail", $connection2) or die ("Couldn't
select database.");
$sql2 = "SELECT dbname FROM productlist WHERE ((accountid =
'printingautomation') OR (accountid = '$accountid')) AND dbname =
'$sel_typeproduct'";

--SNIP--

// MAKE SURE IT IS A PRODUCT THAT HAS PRICING SET FOR IT
$connection3 = mysql_connect("localhost", "root") or die ("Couldn't
connect to the server.");
$db3 = mysql_select_db("priceretail", $connection3) or die ("Couldn't
select database.");
$sql3 = "SELECT companyid FROM $sel_typeproduct WHERE companyid
--SNIP--

Yes, it DOES say root in the script.
Here's what I'm wanting to do: make a script that contains the two
mysql_connect and mysql_select_db lines and then do a require() or
require_once() to call it. (And set up and use a different account
than root.)

Now, the questions:
Should I use require or require_once?
And is there a reason why the connection is established multiple times
that I don't understand? Can't it be established once at the top and
use new mysql_query's each time?

View Replies !
More Efficient Than Regexes For Parsing Data?
I ask this question because I've developed a contact management system for our company and I hook that up to the swish-e search engine. The problem is that swish-e does not as yet have an api for php. I therefore run swish-e, get the results and parse through it with regexes. Typical results for one of my situations looks like

1000 somepage.php?id=1234&name=Robert "somepage.php?id=1234&name=Robert" 805

The first number is the rank and the last is the file size. The stuff in between is parameters I want it to return.

The bottom line is I parse that line (and many more like it) and drop it in an array of associative arrays. Regexes work fine, but there are instances that I get back 10,000 results. And unfortunately, I actually have to return all 10K on one page. With that many results, sometimes it take a minute to run. And I string everything together and do one print statement, so the printing doesn't take much time at all.

My question is, assuming that my regex is as efficient as possible, how can I speed up parsing? I know that in general, string functions are faster than regexes. However, in this case, I have to use too many string functions to get the equivalent in a regex.

View Replies !
PHP Script - Efficient Use Of Execution Time
I am working on a project that requires me to parse 52,005,167 rows in
a MySQL table. I am using a series of PHP scripts for each test I
would like to run on the data. For example I have one test that is to
look for fields with consecutive values. If a row is found to have
more than 4 fields containing consecutive values I would like to
remove the row from the table.

I understand that this will take a good deal of time to process, which
is not a problem. What I am wondering is, should I disable the
maximum script execution time?

Currently I am running these tests in blocks of 10,000 rows at a time.
I would like to just run a test and let it run from start to finish.

View Replies !
Most Efficient Way Of Parsing Text From A File
is there a fastest and most efficient way of parsing text from a file using php's built in function?

the file contains data delimited by some character like '&' and by new lines. i use the "file" function to convert the lines into array then use foreach to read each line then use "parse_str" to get the data i need ...

View Replies !
Most Efficient Way To Mimic A Superglobal Variable
My website allows users to search Amazon. Amazon limits me to one request/second. The site needs to keep track of when the last request was sent and, if it was less than one second ago, wait a moment before sending the next.

What is the best way to handle this? I could save and read a single field from a single row of a MySQL table. Is there a better way? If there isn't does anyone have any advice about the fastest way to do the MySQL?

View Replies !
Most Efficient Way To Do This Cross-table Query?
I have something that works fine, but it's overly redundant and I'm sure it can be made more efficient. I have this query: Code:

View Replies !
When Does Assigning Variables Become More Efficient Than $_POST
This may not be a big deal, but I'm just kinda curious. If I have a
page that submits a form to itself, when is it better to assign each
element in $_POST to a variable to use for the rest of the page?

My situation probably doesn't make a difference, but say I have about
10 form fields, and when the page is posted back to itself, i call
each of those form fields 2 times (1 for error checking, 1 for SQL
insert, or to pre-fill form).

So where does it become more efficient to only call $_POST once and
assign those to variables? Do you use the variables if they are
needed any more than one time?

View Replies !
Cleanest/Most Efficient Email Form
I'm getting my first non-Windows hosting plan and would like to setup a simple contact form. Just the normal 4 fields or so (name, email, subject, comments), and have it spit off an email. I wanted to check if there were any preferred examples, as I'd like something basic, clean and efficient. :)

View Replies !
Most Efficient Way To Load / Store Form Vars
I have a form with about 100+ options on it. I'm looking for the most efficient way to store and retrieve the form variables from a mysql database. The form consists mainly of checkboxes and drop down lists with a few radio buttons.

What I need to do is to determine if the form was loaded as new (a blank sheet), or was called via a 'previous saved form' option.

That bit is easy but it looks like it's going to be a huge job to code the form for loading preset values. I'm wondering if there is an easier way than this: Code:

View Replies !
Search A File/more Efficient To Use A String Or Array?
I'm aware PHP can read the entire contents of a file into a string then from there it's possible to search that string for some data. And I'm also aware that PHP can read the entire contents of a file into an array then from there it's possible to search that array for some data.

But can PHP search a file (such as a .txt or .html file) for a string of data?
If not, then I guess I'm stuck with the first two options I listed. In that case, lets say I have a .txt file with a bunch of text in it.

I want to locate a specific phrase within that text file. Is it more efficient (faster results) to read the contents of that .txt file into a string or an array? Then perform the search.

View Replies !
Process To Compare Records For Updating, Is There Am Efficient Technique?
I have a large database where the records have many fields (80+) and have users periodically updating it by submitting uploads.

Is there a quick and efficient manner to compare the record that is being uploaded to the one that already exists in the DB before updating?

The records have over 80 fields, so stepping through every field would be painful, and why update the record if nothing has changed.

Is there some binary or boolean manner to weight both the existing record against that being offered, and if they are equal then do not go through the process of uploading and importing.

Any ideas welcome.

View Replies !
Whats The Most Efficient Way To Split An Associative Array At Defined Keys?
whats the most efficient way to split an associative array at defined keys? the main purpose of this is to delimit a $_POST request with key/value pairs that identify what form they belong to. Like: Code:

View Replies !
The PHP XML-parser Doesn't Like &lt; Or &gt; ??
I'm using PHP's SAX parser to parse an XML file and display it as a chat-style application.

However, to prevent people posting tags, I'm using htmlspecialchars() to convert <, > and ". These go into an XML document fine.

Once it comes to parsing, the parser seems to interpret < and > as actual XML tags though, and it messes up everything. Is this a known bug, or is there a way of combatting it?

View Replies !
Php-xml Parser
I have a PHP script which sends a authorisation request to a Servlet and receives a response in XML format. I have also created a parser (using both DOM as well as SAX) for parsing the output.

My problem: The parser takes in input from an external xml file but the output from the servlet needs to be dynamically fed into the parser something like this: PHP Code:

View Replies !
Php Parser
I like to know wheter it is possible with php to do the following
taskes:
- read a file (.txt, .doc, .pdf, ...) word by word to chek if a word
or a sentencs exists...
- chek the form of presentation of a word i.e. chek if the word is
bold, in which size, is it centered or aligned to left,...

View Replies !
PDF Parser
i am trying to make a PDF parser in PHP which will be able to extract
data from PDF files. i want to basically convert pdf files to XML
data. any idea from where i could start?

View Replies !
XML Parser
I have a very complex xml doc which if convert into array gives you a lot of nested array.
i wanted some good parser which would parse this complex xml data.
any idea about a good parser or code..which would work on php 4.4.4
I want to extract values from one offset tag and get those extracted values to the DB.

View Replies !
Rss Parser
im using this script that somebody else has made. well some feeds work just fine, some feeds end up with nothing in the item array at all and some feeds come up with this fopen error. Code:

View Replies !
DOM XML Parser
Can we parse Xhtml file using DOM XML parser of PHP. What i really want is this, I have an xhtml file and i want to edit/delete some of the contents in that xhtml file. Xhtml file is organized into parts using <div> tags. this is how it looks like,

<div id="book1">
this is the book introduction part.
<div id="part1">
This is the part introduction
<div id="sec1">
This is the section intrduction
<div id="subSec1">This is the sub section introduction</div>
</div>
</div>
</div>

now what i want is to get the contents that resides inside the <div> tag and edit / delete that content. Which <div> tag to choose, is depending on the parameter i passes and the parameter i pass to the script will hold the <div> id . So according to that i know which <div> tag to choose. Can i do this using XML parser.

View Replies !
Parser
can anyone give me a good defination of a parser, (ive used it to take text from one website and put it into another) but i need some background knowledge of the workings of a parser etc.

View Replies !
Parser?
I am in the process of creating a parser, the following is the code i have started with:

<?php
/*  &copy; MMVI weiqiang's minisite productions
    This programme is intented to be used only on weiqiang's minisite,and no unauthorised usage is allowed.
    You may use the programme if only granted permission by the author.
    Programme filename: manager.php
    Programme function:
    Programme authorised to: Original Copy(weiqiang's minisite)
*/
/*Start Of Programme*/
function parsedocument($document,$returnview=null){
    //document is with regards to root folder
    if(stristr($document,'.php')){
        $handle = fopen($document, "r");
        $contents = fread($handle, filesize($document));
        fclose($handle);
        sprintf($contents);
        preg_replace("{title}","$title",$content);
    }
    /*elseif(!stristr($document,'.php')){
        die(error_note(1010));
        return false;
    }*/
}
parsedocument('bbcode.php');
?>

But i am having a problem of "printing" out the final code
as print() does not support anything other than variable,html and characters right?I mean it doesn't suppot those "<?php" and "?>".

View Replies !
SQL Parser
IS there a script out there in PHP that can run over a simple SQL statement a report in plain english what it will do? E.g.

Updating data in company table
name is now xxx
date is now xxx.

View Replies !
How To Use My Own Parser?
My web host's PHP doesn't provide curl, so I want to run .php files thru my own PHP parser. However, I don't want to rename all the .php files into .cgi files and add some #!/path/to/php as the first line. Code:

View Replies !
Best Xml Parser
I need to use some Ajax for a site running PHP, I was wondering which
is the best xml parser to use?

View Replies !
Css Parser
is there any reason for this script not to work? after trying various ways of reading in the css files for some reason all im getting is the echo statements at the bottom. Code:

View Replies !
XML Parser Installation
I am using RH 7.1 with Php4.1.0 and Apache 1.3.22 .... I have installed libxml and zlib also configured php with dom support. now problem is that when i try to open xml file it gives following error:

Fatal error: Call to undefined function: xmldocfile() in /development/test.php on line 19
any idea where is the problem ?

View Replies !
Parser Question
I would like to make a simple parser which should work as follows:

this is my text {link:href=mypage,link_text} some other text
{link:href=otherpage,other_description}

This is a string I would like to store in the database and then load
in php. Later I would like to insert some other text between { and }
signs. I would have a function name "link" with one parameter passed.
Return value of this function would be a string to replace that one
between { and } signs.

function link($params)
{
... some logic ...
return string;
}

This function will return something like <a
href="/mydir/some_file.php">link_text</a>

View Replies !
Simple Parser In PHP?
I'm coming to the end of a large and exhausting project, done in my
new favorite language PHP, and its time for a diversion.

I'm wondering if anyone has experience with writing simple parsers. I've
never done it myself, but I know they are not as mysterious as they may
seem, it's a matter of finding the tools.

The idea is to take something like CSS format, except that it allows
nesting, and turn it into associative arrays, such as:

anykey {
property: value;
property: value;
nestedkey {
property: value;
property: value;
}
}

could be processed by a command like:

<?php
$parsed = ParseMyFile(...)
?>

and $parsed would hold the same as if we'd done this:

$arr = array(
anykey("property"=>"value",...

View Replies !
Stand Alone PHP Parser
I'm wondering if someone could give some direction on a problem I have
or share their experiences.

I'm wanting to create a little PHP application that will run on a
local machine and use ODBC to connect to a Access database on that
machine. A series of forms will interact with the database but if I
understand correctly, I need some way to parse the PHP code. Is there
a stand alone parser that could be used in place of a HTTP server?

View Replies !
Php Parser And Editor
Does anyone know of a HTML/PHP editor that has syntax highlighting support for PHP and HTML and a Windows/DOS based parser for checking the PHP syntax? At the minute I write in notepad, upload to my site and run it, which isn't ideal. I have various HTML editors but they only allow the addition of simple tags. Linux is out of the question, as I only have Windows on my works computer.

View Replies !
Html Parser For Php
i need to parse an html document from a PHP script. i want to extract the URLs in <a>, <img>,etc. tags, make some changes (which i know how todo with regexp) and then output the HTML document with url changed. is there something as perl-HTML-Parser in PHP
or i have to program it myself?

View Replies !
Simple XML Parser
I am trying to write a simple XML parser with PHP. What would be the best way to assign the string/text stored in between <TAG> … and … </TAG> to a variable? The 'content' between the XML tags can have multiple lines and may contain other html tags.

View Replies !
Xml & Xsl Parser Method?
I have 3 xml files and they are connected with 3 different xsl pages..

i want to make a Object Class that first build up the first xml.. then the 2
etc and parse it in 1 time together..

or how can i merge 3 different xsl files and xml at the same time together
and with the DOM parser memdump() all? at once..?

[Project]
I have a header.. that is also dynamicly fron database, a main content from
database and a static footer..
so i need to make first a UML static case.. and then programm the classes
and parse them in html :)


View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved