Geeks Talk

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.

Query into xinclude (included xml) using xpath

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 ...

Go Back   Geeks Talk > Web Development > PERL
Register Blogs FAQ Tag Cloud Calendar Mark Forums Read

PERL PERL Scripts - Tips, Tricks, Issues, Latest News, PERL Resource and PERL related topics can be discussed in this forum.

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-30-2009
Junior Member
 
Join Date: May 2008
Location: India
Posts: 26
Thanks: 1
Thanked 1 Time in 1 Post
sajithkutty is on a distinguished road
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>
child.xml
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<childroot>
    <childelement processname="myprocess" process_input_file="${[//dir@mypath]}/myinputfile.txt"></childelement>
</childroot>
Since child.xml is included in main.xml, i thought i could write the following code to get the value of "process_input_file".

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";
  }
}
But it doesn't work. Can I query into included xml file through the parent xml (here main.xml) using xpath? If not, is there an alternative?

Thanks
Sajith

Last edited by sajithkutty; 05-30-2009 at 01:10 PM.
Reply With Quote
Sponsored Links
Reply

  Geeks Talk > Web Development > PERL

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


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


All times are GMT -4. The time now is 11:26 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.1
Copyright © 2009 GeekInterview.com. All Rights Reserved