Toggle navigation
Toggle navigation
This project
Loading...
Sign in
박정인
/
opensource
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
박정인
2017-12-06 21:49:14 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d44d780aac272407980e58a3d5c321da68163d63
d44d780a
1 parent
ad6979b9
import xml
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
0 deletions
import.php
import.php
0 → 100644
View file @
d44d780
<?php
require
(
"import.php"
);
function
parseToXML
(
$htmlStr
)
{
$xmlStr
=
str_replace
(
'<'
,
'<'
,
$htmlStr
);
$xmlStr
=
str_replace
(
'>'
,
'>'
,
$xmlStr
);
$xmlStr
=
str_replace
(
'"'
,
'"'
,
$xmlStr
);
$xmlStr
=
str_replace
(
"'"
,
'''
,
$xmlStr
);
$xmlStr
=
str_replace
(
"&"
,
'&'
,
$xmlStr
);
return
$xmlStr
;
}
// Opens a connection to a MySQL server
$connection
=
mysql_connect
(
'localhost'
,
$username
,
$password
);
if
(
!
$connection
)
{
die
(
'Not connected : '
.
mysql_error
());
}
// Set the active MySQL database
$db_selected
=
mysql_select_db
(
$database
,
$connection
);
if
(
!
$db_selected
)
{
die
(
'Can\'t use db : '
.
mysql_error
());
}
// Select all the rows in the markers table
$query
=
"SELECT * FROM seoul WHERE 1"
;
$result
=
mysql_query
(
$query
);
if
(
!
$result
)
{
die
(
'Invalid query: '
.
mysql_error
());
}
header
(
"Content-type: seoul/xml"
);
// Start XML file, echo parent node
echo
'<markers>'
;
// Iterate through the rows, printing XML nodes for each
while
(
$row
=
@
mysql_fetch_assoc
(
$result
)){
// Add to XML document node
echo
'<marker '
;
echo
'name="'
.
parseToXML
(
$row
[
'name'
])
.
'" '
;
echo
'address="'
.
parseToXML
(
$row
[
'address'
])
.
'" '
;
echo
'lat="'
.
$row
[
'lat'
]
.
'" '
;
echo
'lng="'
.
$row
[
'lng'
]
.
'" '
;
echo
'type="'
.
$row
[
'type'
]
.
'" '
;
echo
'/>'
;
}
// End XML file
echo
'</markers>'
;
?>
Please
register
or
login
to post a comment