I am using XML::LibXML to parse my xml file that has an schema file associated with it. My xml document has namespace and schema location defined in it. When I try and parse the document to get the nodelist I get nothing, but if I remove the namespace and schema location information from the xml document it works... below is my code and part of xml file..
use XML::LibXML;
my $parser = XML::LibXML->new();
my $data = $parser->parse_file($xml_file);
my @nodes = $data->findnodes("/info/city");
xml_file:
<?xml version="1.0"?>
<info
xmlns="http://www.mydomain.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mydomain.com infoschema.xsd">
<name>john</name>
<city>baltimore</city>
<zip>21205</zip>
</info>
do I need to set something ..am I forgetting something
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.