libxml2

How can libxml2 be used to parse data from XML?

时光总嘲笑我的痴心妄想 提交于 2019-11-28 07:43:31
I have looked around at the libxml2 code samples and I am confused on how to piece them all together. What are the steps needed when using libxml2 to just parse or extract data from an XML file? I would like to get hold of, and possibly store information for, certain attributes. How is this done? I believe you first need to create a Parse tree. Maybe this article can help, look through the section which says How to Parse a Tree with Libxml2 . I found these two resources helpful when I was learning to use libxml2 to build a rss feed parser. Tutorial with SAX interface Tutorial using the DOM

#import <libxml/tree.h> file not found after xcode update

让人想犯罪 __ 提交于 2019-11-28 07:12:11
Lastnight I updated my iPhone to iOS 6.1, my current version of xcode wouldn't build to the phone as I needed the newest version. I went from xcode 4.5.2 to xcode 4.6, I made 0 changes in my project file. What used to compile completely fine, now gives me a file not found error #import <libxml/tree.h> 'libxml/tree.h' file not found I have my search paths correctly linked up with $(SDKROOT)/usr/include/libxml2 and libxml2 is linked and required in build phases. Edit: Peculiar I changed my search paths to the following and voila.. /usr/include/libxml2 Not sure why this has fixed this issue,

How to load correct version of dynamic libraries and gems (libxml, Nokogiri) within a custom Rails engine gem?

风流意气都作罢 提交于 2019-11-28 05:45:00
问题 I am building a rails engine that uses the Nokogiri gem and I'm having trouble with my development setup in MacOS 10.7 and 10.8: In order for Nokogiri to work properly in my setup, I updated the libxml and libxslt libraries with: brew update brew install libxslt brew upgrade libxml2 gem uninstall nokogiri gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.9.0/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.0/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1

Libxml2 missing mac os x 10.10

独自空忆成欢 提交于 2019-11-28 03:58:29
Running 'compile' for libxslt 1.1.28... OK Running 'install' for libxslt 1.1.28... OK Activating libxslt 1.1.28 (from /Users/Kartik/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/nokogiri-1.6.4.1/ports/x86_64-apple-darwin14.0.0/libxslt/1.1.28)... checking for main() in -llzma... yes checking for xmlParseDoc() in libxml/parser.h... no checking for xmlParseDoc() in -lxml2... no checking for xmlParseDoc() in -llibxml2... no libxml2 is missing. Please locate mkmf.log to investigate how it is failing. *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary

xmllint validation error “no DTD found” while using XSD

天涯浪子 提交于 2019-11-27 21:40:24
问题 I'm trying to use xmllint to check my work while developing a basic XSD i.e. XML Schema schema. However it's giving me an error Validation failed: no DTD found. What am I doing wrong? My xmllint command: xmllint --noout --valid --schema simple.xsd lucas-basic.xml lucas-basic.xml:5: validity error : Validation failed: no DTD found ! > ^ lucas-basic.xml validates Test XSD file: <?xml version = "1.0" encoding = "UTF-8"?> <!--Generated by XML Authority. Conforms to w3c http://www.w3.org/2001

LibXML2.dylib and Xcode4

女生的网名这么多〃 提交于 2019-11-27 18:52:50
I just downloaded Xcode 4 and I cant seem to run my application as the MGTwitter... classes are complaining of a non inclusion error of LibXML2. I have imported it into the frameworks folder, and I have put the following in the header bit in the build settings $(SDKROOT)/usr/include/libxml2 But I am still getting 65 errors. Any ideas how to fix this? Try this: "$(SDK_DIR)"/usr/include/libxml2 sundsx LibXML2 library solved Many confusion around this issue. SOLUTION if you have both Xcode 4.3.x & Xcode 4.5 in /Application folder must add ONLY: /usr/include/libxml2 in Application TARGET > Header

libxml2 error with namespaces and xpath

强颜欢笑 提交于 2019-11-27 17:45:07
问题 I am pasting some code here that compiles with no warning using gcc file.c -lxml2, assuming that libxml2 is installed in your system. #include <libxml/parser.h> #include <libxml/xpath.h> #include <assert.h> #include <libxml/tree.h> #include <libxml/xpathInternals.h> xmlDocPtr getdoc (char *docname) { xmlDocPtr doc; doc = xmlParseFile(docname); if (doc == NULL ) { fprintf(stderr,"Document not parsed successfully. \n"); return NULL; } return doc; } xmlXPathObjectPtr getnodeset (xmlDocPtr doc,

How do I return '' for an empty node's text() in XPath?

筅森魡賤 提交于 2019-11-27 15:33:14
<td></td><td>foo</td> I would like to return ['', 'foo'] but libxml's xpath //td/text() returns just ['foo'] . How do I find the empty tag as '' instead of (not matched)? As long as you are selecting text nodes specifically, you can't. Because there simply is no text node in the first <td> . When you change your XPath expression to '//td' , you get the two <td> nodes. Use their text value in further processing. While @Tomalak is perfectly right, in XPath 2.0 one can use : //td/string(.) and this produces a sequence of strings -- each one containing the string value of a corresponding td

Adding libxml2 in XCode

时间秒杀一切 提交于 2019-11-27 12:20:15
问题 I have added libxml2 to my Xcode 4 project following this guide. But it's not working. Xcode gives me error saying it no such libxml2 directory. What am I doing wrong? Here's the screenshots of the target settings of my project: Thanks. 回答1: add ${SDKROOT}/usr/include/libxml2 to "Header Search Paths" instead of "User Header Search Paths" under yourtarget -> Build Settings -> Search Paths link with libxml2.dylib in yourtarget -> Build Phases -> Link Binary With Libraries include libxml2

How check if a String is a Valid XML with-out Displaying a Warning in PHP

强颜欢笑 提交于 2019-11-27 10:26:35
问题 i was trying to check the validity of a string as xml using this simplexml_load_string()Docs function but it displays a lot of warning messages. How can I check whether a string is a valid XML without suppressing (@ at the beginning) the error and displaying a warning function that expec 回答1: Use libxml_use_internal_errors() to suppress all XML errors, and libxml_get_errors() to iterate over them afterwards. Simple XML loading string libxml_use_internal_errors(true); $doc = simplexml_load