Hello I need to do a form that writes to a database I know how to do that What I dont now how to do is how I dump my data from the db as XML

I want the data to come out like this on the xml

<jobs>
<job id="5575757" title="Teacher" company="Mesa Public Schools" location="Mesa, AZ" />
<job id="8585858" title="Teacher" company="Tempe Public Schools" location="New York, NY" />

</jobs>

Any Ideas Thank you

Recommended Answers

All 3 Replies

Use concatenate . and escaping \ operators like:

echo "<job id=\"". $result['id'] ."\" title=\"". $result['title'] ."\" company=\"". $result['company'] ."\" location=\"". $result['location'] ."\" />";

In this way we have the result in xml syntax.

Use concatenate . and escaping \ operators like:

echo "<job id=\"". $result['id'] ."\" title=\"". $result['title'] ."\" company=\"". $result['company'] ."\" location=\"". $result['location'] ."\" />";

In this way we have the result in xml syntax.

Ok but I will create a table call jobs right and the fields will be

Job_id

Title

Company

Location


Am I right?

Thank you

Yes, more difficult is to put xml data to db. Depending on your PHP version, if it is 5 you can use built-in SimpleXML functions, or in case if it is PHP4 you will need a class to parse xml to an array. Both cases will provide to you access to element attributes in a variable to put afterwards in db.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.