i've a string and it has to be converted to xml file by looking at some certain rule .
string in DB column is like ,
I) Title I
II) Titre II
A. Sous-Titre A
B. Sous-titre B
III) Titre III
A. sssSous-Titre A
B. xxxxSous-Titre Bf
so above string should be stored as a xml file in the format ,
<?xml version="1.0" encoding="iso-8859-1" ?>
<DOCUMENT>
<part1 identifier="1">
<name>Title I</name>
</part1>
<part2 identifier="2">
<name>Titre II</name>
<part21 identifier="21">
<name>Sous-Titre A</name>
</part21>
<part22 identifier="22">
<name>Sous-titre B</name>
</part22>
</part2>
<part3 identifier="3">
<name>Titre III</name>
<part31 identifier="31">
<name>sssSous-Titre A</name>
</part31>
<part32 identifier="32">
<name>xxxxSous-Titre Bf</name>
</part32>
</part3>
</DOCUMENT>
what way it will be better do the above task.
thanks in advance.
converting string to xml file
Moderator: General Moderators
converting string to xml file
Last edited by shivarnm on Thu Jan 13, 2011 4:06 am, edited 1 time in total.
- greyhoundcode
- Forum Regular
- Posts: 613
- Joined: Mon Feb 11, 2008 4:22 am
Re: converting string to xml file
Code: Select all
<part21 identifier="21">
<name>Sous-Titre A</name>
</part21>
<part22 identifier="22">
<name>Sous-titre B</name>
</part22>Re: converting string to xml file
thanks greyhoundcode for ur reply,
am not using any schema, not sure ad hoc . at the end i've to save the string in xml file, its the requirement.
am not using any schema, not sure ad hoc . at the end i've to save the string in xml file, its the requirement.
-
kalpesh.mahida
- Forum Commoner
- Posts: 36
- Joined: Wed Oct 06, 2010 7:09 am
Re: converting string to xml file
Using DOM library you can easily create XML files from SQL data.
Take a look at few articles, hope those will help you.
http://www.tonymarston.net/php-mysql/dom.html
http://www.ibm.com/developerworks/library/os-xmldomphp/
Take a look at few articles, hope those will help you.
http://www.tonymarston.net/php-mysql/dom.html
http://www.ibm.com/developerworks/library/os-xmldomphp/