libxml

libxml2-p25 on OS X 10.5 needs sudo?

When trying to use libxml2 as myself I get an error saying the package cannot be found. If I run as as super user I am able to import fine. I have installed python25 and all libxml2 and libxml2-py25 related libraries via fink and own the entire path including the library. Any ideas why I'd still need to sudo? ...

how to use libxml2 to modify an existing xml file?

I need to take an existing xml file, and modify just a few attributes and write the file back out. I was thinking of using libxml2 to get this done. Application is C/C++ running on Linux. Thing is, libxml2 seems to include several variations of the kitchen sink, along with portable washrooms, showers, and various other things connecte...

Is it possible to use libxml with unicode xmlchar?

Is it possible to use libxml with unicode? For example the xmlParseDoc function takes an xmlChar xmlChar has the following definition: typedef unsigned char xmlChar; I would like for libxml to interpret all as 2 byte chars. I have a feeling that the following would not work properly with the lib: typedef unsigned short xmlChar; ...

Dynamic Variables in XSLT

Hi, I'm passing in a bunch of key-value pairs as parameters to a XSL (date -> "20th January", author -> "Dominic Rodger", ...). These are referenced in some XML I'm parsing - the XML looks like this: <element datasource="date" /> At present, I can't work out how to get 20th January out of these except with a horrible <xsl:choose> st...

What's the best XML parser for Perl?

I have tried many of the Perl XML Parsers. I was quite interested in the Sablotron Parser, but it is such a pain to install on a Windows box. Currently I have started using XML::LibXML and XML::LibXSLT both of which seem to do everything I need. They seem to be quite standard as well. Are there any better XML Parsers to use than th...

How to apply successively two xpath expressions with libxml?

Hi, To sum up, i'm a totally beginner in libxml and I have to use an existing source code. The main idea is to apply a first xpath expression to extract a set of nodes from an xml file. Then, for each node, the second xpath expression shall be applied to extract some values. Existing source code is: int xt_parseXmlResult(xmlDocPtr doc...

Perl, LibXML and Schemas

I have an example Perl script which I am trying to load and validate a file against a schema, them interrogate various nodes. #!/usr/bin/env perl use strict; use warnings; use XML::LibXML; my $filename = 'source.xml'; my $xml_schema = XML::LibXML::Schema->new(location=>'library.xsd'); my $parser = XML::LibXML->new (); my $doc = $parse...

html parsing with libxml

In another thread I got convinced into using HTML parsers instead of regexps for HTML parsing. I thought of using libxml (it has some HTML parser built in), but failed to find any useful tutorial. I also found this site and it says here it should do fine even with severely broken HTML. Could you give me some examples of HTML parsing wit...

How do I tell libxml-ruby about external entity files?

I'm trying to validate using libxml-ruby's DTD#validate, but I keep getting the following warnings: Warning: failed to load external entity "xhtml-lat1.ent" at :29. Warning: failed to load external entity "xhtml-symbol.ent" at :34. Warning: failed to load external entity "xhtml-special.ent" at :39. I wouldn't mind, except I use things...

How can I sort XML entries with LibXML and Perl?

I'm parsing an XML file with LibXML and need to sort the entries by date. Each entry has two date fields, one for when the entry was published and one for when it was updated. <?xml version="1.0" encoding="utf-8"?> ... <entry> <published>2009-04-10T18:51:04.696+02:00</published> <updated>2009-05-30T14:48:27.853+03:00</updated> <ti...

Validation of XML file against XSD in Ruby

Hi I'm trying to validate the following XML against a XSD schema using Ruby. It simply won't work, stops with an error message telling me Error: Element 'request': No matching global declaration available for the validation root. Maybe it's the namespace? I'm desperate. Please help. Thanks! XML: <?xml version="1.0" encoding="UTF-...

How can I fix the "Couldn't create file parser context for file ..." bug with Perl libxml on Debian ?

When I try to read an XML file with XML::Simple, sometimes I get this error message: Couldn't create file parser context for file ... After some googling, it seems to be a problem with libxml-libxml-perl and is supposed to be fixed in the version I use (1.59-2). Any ideas? Edit: (code) sub Read { my ($file, $no_option) = @_; ...

How can I use Perl's XML::LibXML to extract an attribute in a tag?

I have an XML file <PARENT > <TAG string1="asdf" string2="asdf" > </TAG > </PARENT> I want to extract the string2 value here.. and also I want to set it to a new value.. How to do that? ...

Problem with libxml character enconding on win32

While parsing some html files with libxml the function xmlParseFile() returns that the code includes non UTF-8 characters How can i modify the default charset of the library to ISO-8859-1 ? Is there any other way to solve this ? PS: The entire development is based on libxml and works in most cases so I can't switch to another library. ...

Jruby LoadError: Could not open any of [xml2, xslt, exslt] WINDOWS

I am running on windows vista 64 bit operating system. Geografikos is a large project created as a masters thesis project by Jeremy Witmer. It is all coded in JRuby. I am currently expanding the project under his guidance however I cannot run his program. The following gems have been installed: C:\work\Code\geografikos>jruby -S gem list...

Problem with namespace and libxml when i use Xpath

hi i've got a problem when i'm using libxml with XPath. I want to parse an youtube playlist : <?xml version='1.0' encoding='UTF-8'?> <feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearch/1.1/' xmlns:media='http://search.yahoo.com/mrss/' xmlns:batch='http://schemas.google.com/gdata/batch' xm...

Multiple values in one attribute (such as class) in simplexml (using PHP)

If I try to add the same attribute twice to an element via simplexml, I get the following error: Warning: SimpleXMLElement::addAttribute() [function.SimpleXMLElement-addAttribute]: Attribute already exists... As a workaround, I'm using if-else statements for the three possibilities: if ($a && $b) { $node -> addAttribute("class", ...

libxml/tree.h no such file or directory

i am getting following errors. I have already added libxml2.dylib to my project, how ever i am getting this type of trouble. Plz any body help me. ...

libxml-ruby and multiple namespaces

having this xml declaration: <didl:DIDL xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:didl="urn:mpeg:mpeg21:2002:02-DIDL-NS" xsi:schemaLocation="urn:mpeg:mpeg21:2002:02-DIDL-NS http://standards.iso.org/ittf/PubliclyAvailableStandards/MPEG-21_schema_files/did/didmodel.xsd"&gt; what is the way to defin...

ruby, libxml getting the child nodes that match an xpath

I need to get the child nodes of a node using XPath as I want to "drill down" into a node. Here's the code I'm trying: xml_ns = 'Document:http://www.google.com/books/' xml_document = XML::Document.file('./test_pages/test.xml') book_xpath = '//Document:View/Document:Books' book_title_xpath = '//Document:Title' xml_document.find...