Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Gxml
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Canek Peláez Valdés
Gxml
Commits
a2951fc7
Commit
a2951fc7
authored
11 years ago
by
Richard Schwarting
Browse files
Options
Downloads
Patches
Plain Diff
examples/c/document_factory.c: add print out of example nodes we create
parent
0368f573
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/c/document_factory.c
+13
-10
13 additions, 10 deletions
examples/c/document_factory.c
with
13 additions
and
10 deletions
examples/c/document_factory.c
+
13
−
10
View file @
a2951fc7
...
...
@@ -5,47 +5,50 @@ int main () {
doc
=
gxml_document_new
();
/* <bookElement> */
/* <bookElement>
</bookElement>
*/
GXmlElement
*
elem
;
elem
=
gxml_document_create_element
(
doc
,
"tagname"
);
elem
=
gxml_document_create_element
(
doc
,
"bookElement"
);
printf
(
"Book element: %s
\n
"
,
gxml_node_to_string
(
GXML_NODE
(
elem
),
FALSE
,
0
));
GXmlDocumentFragment
*
docfragment
;
docfragment
=
gxml_document_create_document_fragment
(
doc
);
printf
(
"Document fragment: %s
\n
"
,
gxml_node_to_string
(
GXML_NODE
(
docfragment
),
FALSE
,
0
));
/* <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"
);
text
=
gxml_document_create_text_node
(
doc
,
"Between the book tags is text!"
);
printf
(
"Text node: %s
\n
"
,
gxml_node_to_string
(
GXML_NODE
(
text
),
FALSE
,
0
));
/* <book><!-- comment: I really like this
one
-->The fault in our stars</book> */
/* <book><!-- comment: I really like this
book
-->The fault in our stars</book> */
GXmlComment
*
comment
;
comment
=
gxml_document_create_comment
(
doc
,
"Here is an XML comment"
);
comment
=
gxml_document_create_comment
(
doc
,
"comment: I really like this book"
);
printf
(
"Comment: %s
\n
"
,
gxml_node_to_string
(
GXML_NODE
(
comment
),
FALSE
,
0
));
/* <![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"
);
printf
(
"CDATA section: %s
\n
"
,
gxml_node_to_string
(
GXML_NODE
(
cdata
),
FALSE
,
0
));
/* <?xml href="style.xsl" type="text/xml"?> */
GXmlProcessingInstruction
*
pi
;
pi
=
gxml_document_create_processing_instruction
(
doc
,
"xml"
,
"href=
\"
style.xsl
\"
type=
\"
text/xml
\"
"
);
printf
(
"Processing Instruction: %s
\n
"
,
gxml_node_to_string
(
GXML_NODE
(
pi
),
FALSE
,
0
));
/* <element id=""> */
GXmlAttr
*
attr
;
attr
=
gxml_document_create_attribute
(
doc
,
"id"
);
printf
(
"Attribute: %s
\n
"
,
gxml_node_to_string
(
GXML_NODE
(
attr
),
FALSE
,
0
));
/* ' (for an apostrophe, ') */
GXmlEntityReference
*
entref
;
entref
=
gxml_document_create_entity_reference
(
doc
,
"apos"
);
printf
(
"Entity reference: %s
\n
"
,
gxml_node_to_string
(
GXML_NODE
(
entref
),
FALSE
,
0
));
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.
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