Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-1.1
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-1.1
Commits
0d63a3ed
Commit
0d63a3ed
authored
Feb 13, 2010
by
Antoine Cellerier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a simplexml lua module to parse an xml into a table.
parent
a0e994c0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
1 deletion
+70
-1
share/Makefile.am
share/Makefile.am
+2
-1
share/lua/modules/simplexml.lua
share/lua/modules/simplexml.lua
+68
-0
No files found.
share/Makefile.am
View file @
0d63a3ed
...
...
@@ -220,7 +220,8 @@ DIST_lua= \
lua/intf/modules/host.lua
\
lua/intf/telnet.lua
\
lua/intf/dummy.lua
\
lua/modules/sandbox.lua
lua/modules/sandbox.lua
\
lua/modules/simplexml.lua
DIST_http_lua
=
\
lua/http/.hosts
\
...
...
share/lua/modules/simplexml.lua
0 → 100644
View file @
0d63a3ed
--[==========================================================================[
simplexml.lua: Lua simple xml parser wrapper
--[==========================================================================[
Copyright (C) 2010 Antoine Cellerier
$Id$
Authors: Antoine Cellerier <dionoea at videolan dot org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
--]==========================================================================]
module
(
"simplexml"
,
package
.
seeall
)
--[[ Returns the xml tree structure
-- Each node is of one of the following types:
-- { name (string), attributes (key->value map), children (node array) }
-- text content (string)
--]]
local
function
parsexml
(
stream
)
local
xml
=
vlc
.
xml
()
local
reader
=
xml
:
create_reader
(
stream
)
local
tree
local
parents
=
{}
while
reader
:
read
()
>
0
do
local
nodetype
=
reader
:
node_type
()
if
nodetype
==
'startelem'
then
local
name
=
reader
:
name
()
local
node
=
{
name
:
''
,
attributes
:
{},
children
:
{}
}
node
.
name
=
name
while
reader
:
NextAttr
()
==
0
do
node
.
attributes
[
reader
:
Name
()]
=
reader
:
Value
()
end
if
tree
then
tree
.
children
[
#
tree
.
children
]
=
node
parents
[
#
parents
]
=
tree
tree
=
node
end
elseif
nodetype
==
'endelem'
then
tree
=
parents
[
#
parents
-
1
]
elseif
nodetype
==
'text'
then
node
.
children
[
#
node
.
children
]
=
reader
:
Value
()
end
end
return
tree
end
function
parse_url
(
url
)
return
parsexml
(
vlc
.
stream
(
url
))
end
function
parse_string
(
str
)
return
parsexml
(
vlc
.
memory_stream
(
str
))
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment