473,811 Members | 2,557 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do you convert xml code into either a table or a text file?

4 New Member
I have this PHP code that searches a online database for books.

Expand|Select|Wrap|Line Numbers
  1. <html>
  2.  
  3. <form method="post" action="getbookxml.php"> 
  4.   <input type="text" name="isbn_no" /> 
  5.   <input type="submit" value="Retrieve Book Details" /> 
  6. </form> 
  7.  
  8. </html>
  9.  
  10. <?php
  11.  
  12. $isbn_no = $_POST['isbn_no']; 
  13. header("Location: http://isbndb.com/api/books.xml?access_key=YSG2I2WU&index1=isbn&value1=$isbn_no");
  14.  
  15.  ?>
There isn't a problem with this part, but the output I receive on the browser is plain XML code like this:

Expand|Select|Wrap|Line Numbers
  1.   <?xml version="1.0" encoding="UTF-8" ?> 
  2. - <ISBNdb server_time="2011-03-18T14:17:06Z">
  3. - <BookList total_results="1" page_size="10" page_number="1" shown_results="1">
  4. - <BookData book_id="a_civil_action_a01" isbn="0679772677" isbn13="9780679772675">
  5.   <Title>A civil action</Title> 
  6.   <TitleLong /> 
  7.   <AuthorsText>Jonathan Harr</AuthorsText> 
  8.   <PublisherText publisher_id="vintage_books">New York : Vintage Books, 1996.</PublisherText> 
  9.   </BookData>
  10.   </BookList>
  11.   </ISBNdb>
Is there a method(using PHP if possible) where this xml code can be either converted into a table or saved as an excel or text file?

I don't want the user to see this XML code. I'd rather the result of their search to be a nice table or a file they can save.

Can anyone assist?
Mar 18 '11 #1
1 3170
Dormilich
8,658 Recognized Expert Moderator Expert
There isn't a problem with this part, but the output I receive on the browser is plain XML code
well, you request an XML document, even redirect to it …

how to process it depends on how you exactly want to do it as there are (as always) many different possibilities
- using XSLT (this transforms XML to some other XML/HTML/Text) (don’t recommend it for you)
- you can save it to disk using file_put_conten ts()
- you can treat it as string (though that may be difficult)
- you can load it into one of PHP’s XML classes (SimpleXML, DOMDocument) and process that.
Mar 19 '11 #2

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

Similar topics

10
7066
by: Padmaja | last post by:
Hello I want to convert a huge delimited text file (of appr 85MB) directly into XML. I dont want to loop through the text file and write as xml, as it is very large file and taking much time. Can any one help me, how to convert Thanks in advance for all your help Best Rgds Padmaja.
3
1269
by: Tobias Froehlich | last post by:
Hi! is it possible to extract all the code of a project (or a single .cs file) into a text file? I mean of course I can just do ctrl-c and ctrl-v, but it would be great if the colors would be kept and if it would be somehow structured.. the problem is that I need to show someone the code of my project, but on his computer there is no VC#. (and no, he can't come watch it on mine :)
3
8558
by: David | last post by:
using c# in VS2003 in compact framework Hi, I am looking for some examples on how to convert a Dataset to text file. My application reads the dataset from SQL Server and displays it in a datagrid. I would like to take the data in the datagrid and send it to a text file. Any suggestions are welcome and appreciated Thanks
3
6703
by: Brad Sanders | last post by:
Hello All, I need a little help with a subject I am not very familier with. I need to place into a text file several HEX codes (0D 0C 0A). If I place these codes into the file with a hex editor then when you open it with notepad the codes show up as boxes (unknown ascii). That is exactly what I need to do from vb.net. How to I write hex codes into my text file?
14
3195
by: Ilias Lazaridis | last post by:
within a python script, I like to create a collection which I fill with values from an external text-file (user editable). How is this accomplished the easiest way (if possible without the need of libraries which are not part of the standard distribution)? something like: text-file: {peter, 16},
5
5150
by: sangith | last post by:
Hi, How do I convert a word document into a text file. (For eg: If I give input as file1.doc, my Perl program should automatically convert it into file1.txt) Is there any Perl module which does this conversion? I would appreciate your response! Thanks in advance! Sangith
3
3188
by: jasvinder singh | last post by:
Respected Sir/madam, Can you help in providing code in 'C' for Reading text file with n number of rows and columns and putting the result in arrays.The sample file is as follows: rim_label = 'aeff5' state 0 = 'eee' state 1 = 'ffffff' . .and so on...
1
1839
by: veenna | last post by:
How can i select utf-8 encoded character fro ma text file and bind it to dataset. Here is the code: Dim srStreamReader As StreamReader Dim sFile As String = "E:\FTPROOT\uni.txt" Dim swfile As String = "E:\FTPROOT\" Dim sFileText As String srStreamReader = New StreamReader(sFile, Encoding.Default) sFileText = srStreamReader.ReadToEnd()
1
1296
by: Hamayun Khan | last post by:
Hi All I have text files having queries like below. INSERT INTO tblJobScrap (,,,,,,,,,) VALUES ('http://www.aberdeencity.gov.uk/webapps/images/genericicons/acc-logo.gif','Aberdeen','Scotland','School Crossing Patroller','No fixed closing date','£6.0100 p.h.','£6.37-£6.65 p.h.','Permanent','','http://www.aberdeencity.gov.uk/webapps/jobs/jobDetails.asp?id=5591') INSERT INTO tblJobScrap (,,,,,,,,,) VALUES...
2
2999
by: devquest | last post by:
I have an xml file, and I need to convert it into a text file. xml: <?xml version="1.0" encoding="UTF-8" ?> - <po-response xmlns="http://seller.marketplace.sears.com/oms/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://seller.marketplace.sears.com//SellerPortal/s/schema/oms/purchaseorder-v1.xsd"> - <purchase-order> <po-number>2180031</po-number> <po-date>2009-12-27</po-date> ...
0
9730
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
10651
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10403
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10136
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
9208
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...
0
5555
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
5693
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4341
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
3868
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.