473,386 Members | 1,793 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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

4
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 3149
Dormilich
8,658 Expert Mod 8TB
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_contents()
- 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
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. ...
3
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...
3
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...
3
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...
14
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...
5
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...
3
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 =...
1
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...
1
by: Hamayun Khan | last post by:
Hi All I have text files having queries like below. INSERT INTO tblJobScrap (,,,,,,,,,) VALUES...
2
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"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...

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.