LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-07-2009, 09:21 PM   #1
tardigrade
Member
 
Registered: Jun 2004
Distribution: SuSE 9.1
Posts: 150

Rep: Reputation: 15
xml with PHP


I have an xml document that I want to extract nodes as a new smaller xml file. Take:
Code:
<root> 
 <sub id="1">
   [Lots of other children]
 </sub>
 <sub id="n">
   [...]
 </sub>
</root>
to a new xml file:
Code:
<root>
 <sub id="1">
  [Lots of other children]
 </sub>
</root>
What I am trying to do is extract each <sub> as a new xml file or string with formatting, which I will output to the browser with
XSLTProcessor::importStyleSheet($xsl)
XSLTProcessor::transformToXML($xml);

I have an xsl document that I can use to transform the whole document. I could modify it to take out the root take, but it would also be nice to wrap each extracted sub document in a <root> tag.

I am really stuck on this. It seems reasonable to me.
Thanks in advance.
 
Old 03-10-2009, 11:20 AM   #2
shakezilla
Member
 
Registered: Jun 2005
Location: U.S.
Distribution: xubuntu 8.10, linux 2.6.27-11-generic
Posts: 78

Rep: Reputation: 16
This has no replies yet, so I'll just make a suggestion. I don't know the first thing about XSLTProcessor, so I can't help you there.

However, I have used simplexml in the past. I thought it was very easy to use, although it obviously is not as powerful or robust as some other libraries. FWIW

Also, if your files are going to be formatted like in your example, it may be easier to just use sed or perl or something. If you can just look for a single line with a <sub> tag, that might be easier than doing real xml parsing.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP XML Parser mindjet Programming 2 05-18-2008 12:43 PM
XML in PHP Vort3x Linux - Software 1 12-20-2004 09:12 PM
PHP w/ XML ridertech Linux - Software 0 05-05-2004 02:50 AM
Php Vs. Xml zetsui Programming 4 02-18-2004 12:57 PM
PHP and XML Bill Barrington Linux - Software 0 06-22-2003 08:08 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:45 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration