Skip to content
GitLab
Explore
Sign in
Commit
152e5267
authored
11 years ago
by
Richard Schwarting
Browse files
Options
Downloads
Patches
Plain Diff
examples/c: add document_factory.c, remove a comment from document_properties.c
parent
26c121c3
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
examples/c/Makefile.example
+1
-1
1 addition, 1 deletion
examples/c/Makefile.example
examples/c/document_factory.c
+52
-0
52 additions, 0 deletions
examples/c/document_factory.c
examples/c/document_properties.c
+0
-1
0 additions, 1 deletion
examples/c/document_properties.c
with
53 additions
and
2 deletions
examples/c/Makefile.example
+
1
−
1
View file @
152e5267
CC
=
gcc
CFLAGS
=
`
pkg-config
--cflags
gxml gio-2.0
`
-g
-Wall
LDFLAGS
=
`
pkg-config
--libs
gxml gio-2.0
`
PROGS
=
create_
document
create
_
document_minimal
create_
document_from_string
create_
document_from_file
create_
document_from_path
save_
document_to_path
save_document_to_stream
PROGS
=
document
_
create
document_
create_
minimal document_
create_
from_string document_
create_
from_file document_
create_
from_path document_
save_
to_path
document_save_to_stream document_properties document_factory
all
:
$(PROGS)
...
...
This diff is collapsed.
Click to expand it.
examples/c/document_factory.c
0 → 100644
+
52
−
0
View file @
152e5267
#include
<gxml/gxml.h>
int
main
()
{
GXmlDocument
*
doc
;
doc
=
gxml_document_new
();
/* <bookElement> */
GXmlElement
*
elem
;
elem
=
gxml_document_create_element
(
doc
,
"tagname"
);
GXmlDocumentFragment
*
docfragment
;
docfragment
=
gxml_document_create_document_fragment
(
doc
);
/* <book>Between the book tags is text!</book> */
GXmlText
*
text
;
text
=
gxml_document_create_text_node
(
doc
,
"Here is some text in an XML document"
);
/* <book><!-- comment: I really like this one -->The fault in our stars</book> */
GXmlComment
*
comment
;
comment
=
gxml_document_create_comment
(
doc
,
"Here is an XML comment"
);
/* <![CDATA[non-XML data like code or special entities]]> */
GXmlCDATASection
*
cdata
;
cdata
=
gxml_document_create_cdata_section
(
doc
,
"non-XML data like code or special entities"
);
/* <?xml href="style.xsl" type="text/xml"?> */
GXmlProcessingInstruction
*
pi
;
pi
=
gxml_document_create_processing_instruction
(
doc
,
"xml"
,
"href=
\"
style.xsl
\"
type=
\"
text/xml
\"
"
);
/* <element id=""> */
GXmlAttr
*
attr
;
attr
=
gxml_document_create_attribute
(
doc
,
"id"
);
/* ' (for an apostrophe, ') */
GXmlEntityReference
*
entref
;
entref
=
gxml_document_create_entity_reference
(
doc
,
"apos"
);
gxml_node_append_child
(
GXML_NODE
(
doc
),
GXML_NODE
(
elem
));
g_object_unref
(
elem
);
g_object_unref
(
pi
);
g_object_unref
(
entref
);
g_object_unref
(
attr
);
g_object_unref
(
docfragment
);
g_object_unref
(
text
);
g_object_unref
(
comment
);
g_object_unref
(
cdata
);
g_object_unref
(
doc
);
return
0
;
}
This diff is collapsed.
Click to expand it.
examples/c/document_properties.c
+
0
−
1
View file @
152e5267
...
...
@@ -8,7 +8,6 @@ int main () {
xml
=
"<?xml version=
\"
1.0
\"
?><!DOCTYPE bookshelf><Bookshelf><Owner fullname=
\"
John Green
\"
/><Books><Book author=
\"
John Green
\"
title=
\"
The Fault in Our Stars
\"
/><Book author=
\"
Jane Austen
\"
title=
\"
Pride & Prejudice
\"
/><Book author=
\"
J.D. Salinger
\"
title=
\"
Nine Stories
\"
/></Books></Bookshelf>"
;
doc
=
gxml_document_new_from_string
(
xml
);
// should be "#document"
const
gchar
*
doc_node_name
;
doc_node_name
=
gxml_node_get_node_name
(
GXML_NODE
(
doc
));
printf
(
"A document's node_name is: %s (which should always be '#document')
\n\n
"
,
doc_node_name
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment