473,948 Members | 1,495 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Read xml file from last entry

134 New Member
hi

i have a xml file which has transaction details of the users.

I m inserting data using appendChild() from php.

While displaying i need to display the last 5 entry or single entry or the whole entries descending using php.

Is there anyway to read the xml file from the lastentry using php...


regards
vijay
Sep 2 '09
16 4331
vjayis
134 New Member
sorry i had not used Xpath and i dont know how to implement it into my code..

could you guide me..
Sep 2 '09 #11
Dormilich
8,658 Recognized Expert Moderator Expert
XPath in SimpleXML: xpath()

XPath Tutorial

XPath is a convenient way to address XML nodes. if you’re familiar with the DOM (e.g. from using Javascript) this shouldn’t be too complicated.
Sep 2 '09 #12
vjayis
134 New Member
thanks i ll gothrough it..

(you could also do a text search, but it would be more complicated to get the items…)
how can i do a text search using php..
Sep 2 '09 #13
Dormilich
8,658 Recognized Expert Moderator Expert
@vjayis
Expand|Select|Wrap|Line Numbers
  1. $xmltxt = file_get_contents("test.xml");
  2. // or whichever search function you need
  3. $pos = strpos($xmltxt, $_date_);
the point is, you need some clever code (probably including RegEx) to get the items from that (the XML is treated as a string, not as XML)
Sep 2 '09 #14
vjayis
134 New Member
thanks

and i had worked an search from an example
Expand|Select|Wrap|Line Numbers
  1. $filename='example.xml';
  2.  
  3. $data = simplexml_load_file($filename);
  4. $op = $data->xpath('/entries/entry[time>1251802411]');
  5.  
  6.    foreach($op as $ops) {
  7.     echo $ops->acno."-".$ops->time."<br />";
  8.    }
  9.  
which outputs

B900326-1251802455
B900326-1251802528
B900326-1251804653
B900326-1251866308
B900326-1251866501

in this how can i search two or more conditions for example.....

acno='B900326' & time>'125180241 1'

how to implement it
Sep 2 '09 #15
Dormilich
8,658 Recognized Expert Moderator Expert
@vjayis
add another square bracket.

Expand|Select|Wrap|Line Numbers
  1. node[condition1][condition2]
Sep 2 '09 #16
vjayis
134 New Member
ohh yeah thanks yar.,

guess its going to be very easy than sql search....

thanks
Sep 2 '09 #17

Sign in to post your reply or Sign up for a free account.

Similar topics

15
5924
by: Ridimz | last post by:
When use ifstream, how do I ignore the last line of a file if it doesn't contain any information? Thanks in advance, Ridimz
5
1674
by: Stanley Yue | last post by:
I made a map like this: typedef struct { char * Source; bool DirFlag; } RegInfo_t; struct Comp {
5
2892
by: Julia | last post by:
Strategy to read part of XML log file Hi, My log file will contains entries formatted as XML(i use this format since some time i would like to log entire objects) I am going to use FileSystemWatcher in order to detect when changes occur to the file and now I am facing a problem reading the last added node I came to the following strategy:
2
5452
by: krukinews | last post by:
Hi, I'm trying to write small program that reads events from computer and stores them in SQL database. But I don't know hove to read logs for let's say last 24 hours, one solution is to read all events in event log and then check time. foreach(EventLogEntry Entry in logSystem.Entries) { //
1
3816
by: MikeY | last post by:
Hopefully someone can help, I have a listview box where I display my desired files. I single click on the desired file to be renamed and I rename it with a new name. My problem arises when the new name gets displayed through refreshing of my loop and display function. The problem is that when, if I rename the last file entry, everything appears to display fine. If I rename a file above the last entry (bottom entry), two of the new file...
1
5378
by: vkrasner | last post by:
It works with VS2003 and does not in VS2005: in VS2003 : string sMyvalue = ConfigurationSettings.AppSettings; in VS2005 (does not work!!) string sMyvalue = ConfigurationManager.AppSettings; Anybody able to give me idea how-to read by C# element which I add to the machine.config into the new single section?
5
5134
by: Sumana | last post by:
Hi All, We developed our project on VC++.Net console application to create image of disk and to write the image We are having problem with reading and writing the sector beyond 6GB Disk or Partition we are using ReadFile , WriteFile and setFilePointerEx to read and write the sectors and we are reading/writing 102400 sectors together, even we have reduced the sectors still it is not able to read or write, our program is working fine...
8
1893
by: kepioo | last post by:
I currently have an xml input file containing lots of data. My objectiv is to write a script that reports in another xml file only the data I am interested in. Doing this is really easy using SAX. The input file is continuously updated. However, the other xml file should be updated only on request. Everytime we run the script, we track the new elements in the input file and report them in the output file.
2
1652
by: Brad King | last post by:
Hello Everyone, I am having trouble reading a file. My eventual plan is to read in the file, fix a formatting problem with a regex and export the changed data to a new file. However my importing skills are not working. Can anyone help me in the right direction? I believe my problem is that I have set lengths for the import and what I should have done is look for the next space. Can anyone show me a snippet that looks for the next...
0
10167
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11182
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10695
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9898
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8258
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6120
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6341
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4950
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4543
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.