Prepare for your Next Interview
|
Welcome to the Geeks Talk forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
This is a discussion on Query into xinclude (included xml) using xpath within the PERL forums, part of the Web Development category; Hi, I have 2 xmls; main.xml and child.xml. child.xml is included in main.xml using xinclude. attribute values in child.xml internally refer to value of attribute in main.xml. sample files are ...
|
|||||||
| PERL PERL Scripts - Tips, Tricks, Issues, Latest News, PERL Resource and PERL related topics can be discussed in this forum. |
![]() |
| LinkBack | Thread Tools | Display Modes |
|
|||
|
Query into xinclude (included xml) using xpath
Hi,
I have 2 xmls; main.xml and child.xml. child.xml is included in main.xml using xinclude. attribute values in child.xml internally refer to value of attribute in main.xml. sample files are as below. main.xml Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<mainroot>
<xi:include href="child.xml"/>
<path name="mypath" value="C:\Work"></path>
</mainroot>
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<childroot>
<childelement processname="myprocess" process_input_file="${[//dir@mypath]}/myinputfile.txt"></childelement>
</childroot>
Code:
#!/usr/bin/perl
use XML::XPath;
my $xp = XML::XPath->new(filename => 'c:/main.xml');
my $nodeset = $xp->find('//mainroot/childroot/childelement');
foreach my $node ($nodeset->get_nodelist) {
$processname = "".$node->find('@processname');
$processinputfile = "".$node->find('@process_input_file');
if ($processname eq "myprocess") {
print "processinputfile=$processinputfile\n";
}
}
Thanks Sajith Last edited by sajithkutty; 05-30-2009 at 01:10 PM. |
| Sponsored Links |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Reading xml files including other xml files using xpath | sajithkutty | PERL | 0 | 05-27-2009 08:07 AM |
| AJAX Made Easy - Ajax XPath | Lokesh M | AJAX & XML | 0 | 11-03-2008 09:40 AM |
| Update query using sub query | ravikumar.drk99 | SQL | 5 | 09-01-2008 04:40 AM |
| Querying a DOM Document with XPath | admin | Web Design | 0 | 04-21-2008 10:00 AM |
| New events included in VB6.0 textbox | Subashini.Ramasamy | VB.NET | 1 | 07-16-2007 02:56 AM |