Skip to content

Commit ad061d4

Browse files
committed
use formatted output
1 parent 9c3fc1d commit ad061d4

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

src/clib.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,7 @@ _xcopystr(p::Xstr) = (r = bytestring(p); _xmlfree(p); r)
5858
@lx2func xmlParseFile
5959
@lx2func xmlParseMemory
6060
@lx2func xmlDocDumpMemoryEnc
61+
@lx2func xmlDocDumpFormatMemoryEnc
6162
@lx2func xmlSaveFileEnc
63+
@lx2func xmlSaveFormatFileEnc
6264

src/document.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ end
100100
#### output
101101

102102
function save_file(xdoc::XMLDocument, filename::ASCIIString; encoding::ASCIIString="utf-8")
103-
ret = ccall(xmlSaveFileEnc, Cint, (Ptr{Cchar}, Xptr, Ptr{Cchar}),
104-
filename, xdoc.ptr, encoding)
103+
ret = ccall(xmlSaveFormatFileEnc, Cint, (Ptr{Cchar}, Xptr, Ptr{Cchar}, Cint),
104+
filename, xdoc.ptr, encoding, 1)
105105
if ret < 0
106106
throw(XMLWriteError("Failed to save XML to file $filename"))
107107
end
@@ -111,8 +111,8 @@ end
111111
function Base.string(xdoc::XMLDocument; encoding::ASCIIString="utf-8")
112112
buf_out = Array(Xstr, 1)
113113
len_out = Array(Cint, 1)
114-
ccall(xmlDocDumpMemoryEnc, Void, (Xptr, Ptr{Xstr}, Ptr{Cint}, Ptr{Cchar}),
115-
xdoc.ptr, buf_out, len_out, encoding)
114+
ccall(xmlDocDumpFormatMemoryEnc, Void, (Xptr, Ptr{Xstr}, Ptr{Cint}, Ptr{Cchar}, Cint),
115+
xdoc.ptr, buf_out, len_out, encoding, 1)
116116
_xcopystr(buf_out[1])
117117
end
118118

src/nodes.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ const DEFAULT_DUMPBUFFER_SIZE = 4096
166166
function Base.string(nd::XMLNode)
167167
buf = XBuffer(DEFAULT_DUMPBUFFER_SIZE)
168168
ccall(xmlNodeDump, Cint, (Xptr, Xptr, Xptr, Cint, Cint),
169-
buf.ptr, nd._struct.doc, nd.ptr, 0, 0)
169+
buf.ptr, nd._struct.doc, nd.ptr, 0, 1)
170170
r = content(buf)
171171
free(buf)
172172
return r

test/create.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,9 @@ add_text(xs2, "Illinois")
1313
set_attribute(xs2, "tag", "MA")
1414

1515
show(xdoc)
16+
17+
show(xroot)
18+
19+
# save_file(xdoc, "tt.xml")
20+
21+
free(xdoc)

0 commit comments

Comments
 (0)