Page 1 of 1

Using XML to format text

Posted: Sat Sep 29, 2007 9:39 am
by Etrai
Hi!
I'm making a homepage for a company right now and thay want it to be easy for them to change the content without having to contact me or my "associates" to get it done. So now I'm at somewhat of a crossroads and I kinda need a nudge in one direction or the other. My problem is this:
The textual content for any given page is stored in an XML file (at the moment). For example "home.xml" which is structured something like this:

Code: Select all

<page>
   <paragraph>Here be some text.</paragraph>
   <paragraph>Here be more text.</paragraph>
</page>
Within the paragraphs I want to enable some sort of text formatting in the form tags, for instance a <bold></bold> tag for making the text bold.

Code: Select all

<page>
   <paragraph>Here be some text, <bold>and it's bold</bold>.</paragraph>
   <paragraph>Here be more text.</paragraph>
</page>
The problem I'm having is that when I parse the XML-file I have no idea where the formatting tags are located within the paragraph tags, and I would like to keep the <> identifiers for tags _and_ not have to parse the document more than once. (I have a solution that would take two passes and use BB-codish syntax.)
Any ideas? Do I need to explain it better? ;)

Posted: Sat Sep 29, 2007 9:57 am
by feyd
Are you using one of the XML parsing libraries available for PHP (as natives)? e.g SimpleXML, DOM...

Posted: Sat Sep 29, 2007 10:58 am
by volka
You might also be interested in XSL.

see also:
http://www.w3schools.com/xsl/
http://de2.php.net/xsl

Posted: Sat Sep 29, 2007 4:30 pm
by Etrai
feyd wrote:Are you using one of the XML parsing libraries available for PHP (as natives)? e.g SimpleXML, DOM...
I'm using SimpleXML at the moment, and I have looked into the xml parser functions and briefly into the DOMDocument class. I know that what I want to do should not be (is not?) possible with SimpleXML
volka wrote:You might also be interested in XSL.

see also:
http://www.w3schools.com/xsl/
http://de2.php.net/xsl
I'll definatly have a look see atleast, thanks =)

Posted: Mon Oct 01, 2007 12:05 pm
by Etrai
Now I've had some time to look at XSL and it doesn't seem to do what I need. Atleast not in a simple enough fashion =/
Any other recommendations or ideas?