Skip to content

Instantly share code, notes, and snippets.

@nico
Created February 12, 2018 02:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nico/97bd26b5f287808ecf2edf8e1c4eb55d to your computer and use it in GitHub Desktop.
Save nico/97bd26b5f287808ecf2edf8e1c4eb55d to your computer and use it in GitHub Desktop.
Nicos-MacBook-Pro:hack thakis$ clang -o xmltest xmltest_libxml.cc -I$(xcrun -show-sdk-path)/usr/include/libxml2 -lxml2 && ./xmltest xmltest_in.xml
xmltest_in.xml:3: namespace warning : xmlns: URI foo is not absolute
<hi xmlns="foo" xmlns:x="bar">
^
1/XML_ELEMENT_NODE hi (null)
3/XML_TEXT_NODE text
1/XML_ELEMENT_NODE hi (null) ((null):foo XML_NAMESPACE_DECL) (x:bar XML_NAMESPACE_DECL)
def ns: ((null):foo XML_NAMESPACE_DECL) (x:bar XML_NAMESPACE_DECL) 3/XML_TEXT_NODE text
7/XML_PI_NODE foobar version="1.0"
3/XML_TEXT_NODE text
1/XML_ELEMENT_NODE ho (null) ((null):foo XML_NAMESPACE_DECL) (x:bar XML_NAMESPACE_DECL)
3/XML_TEXT_NODE text text&more@
1/XML_ELEMENT_NODE ho (null) (x:bar XML_NAMESPACE_DECL)
2/XML_ATTRIBUTE_NODE attr (null) (x:bar XML_NAMESPACE_DECL)
3/XML_TEXT_NODE text adsf
3/XML_TEXT_NODE text
8/XML_COMMENT_NODE comment adsf
3/XML_TEXT_NODE text
3/XML_TEXT_NODE text
4/XML_CDATA_SECTION_NODE (null) my cdata
3/XML_TEXT_NODE text
1/XML_ELEMENT_NODE ho (null)
3/XML_TEXT_NODE text
@nico
Copy link
Author

nico commented Feb 12, 2018

`C:\src\llvm-build-goma10>xmltest ..\hack\xmltest_in.xml
9/document #document (null) (null)
  7/processinginstruction xml version="1.0" encoding="utf-8" (null)
    2/attribute version 1.0 (null)
      3/text #text 1.0 (null)
    2/attribute encoding utf-8 (null)
      3/text #text utf-8 (null)
  1/element hi (null) (null)
    1/element hi (null) foo
      2/attribute xmlns foo http://www.w3.org/2000/xmlns/
        3/text #text foo (null)
      2/attribute xmlns:x bar http://www.w3.org/2000/xmlns/
        3/text #text bar (null)
      7/processinginstruction foobar version="1.0" (null)
      1/element ho (null) foo
      3/text #text text&more@ (null)
      1/element x:ho (null) bar
        2/attribute x:attr adsf bar
          3/text #text adsf (null)
      8/comment #comment  adsf  (null)
    4/cdatasection #cdata-section my cdata (null)
    1/element ho (null) (null)`

@nico
Copy link
Author

nico commented Feb 12, 2018

<?xml version="1.0" encoding="utf-8"?>
<hi>
  <hi xmlns="foo" xmlns:x="bar">
    <?foobar version="1.0"?>
    <ho
    />text&amp;more@<x:ho x:attr="adsf"/>
    <!-- adsf -->
  </hi>
  <![CDATA[my cdata]]>
  <ho/>
</hi>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment