Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Xml::Twig:Xpath Xpath expression error

by mirod (Canon)
on Apr 14, 2009 at 11:33 UTC ( #757373=note: print w/replies, xml ) Need Help??


in reply to Xml::Twig:Xpath Xpath expression error

Without the XML it's a bit hard to figure out what you are trying to do here, or to test anything, but if Name is an attribute, you need to write @Name in the query.

Updated: oops! I had '#' instead of '@', fixed now.

  • Comment on Re: Xml::Twig:Xpath Xpath expression error

Replies are listed 'Best First'.
Re^2: Xml::Twig:Xpath Xpath expression error
by leonidlm (Pilgrim) on Apr 14, 2009 at 14:01 UTC
    Thank you.
    It didn't help. By adding @ to the Name I escaped the error message but didn't get a desired result! Why with the same expression XML:XPath get me good output?
    Portion of the xml this sub will process:
    <OverallConnectionPoolStatus> <FlowRater> <Name>Total.IncomingReq</Name> <Rate>0</Rate> <LastMinRate>0</LastMinRate> <Counter>209</Counter> </FlowRater><FlowRater> <Name>Total.RejectedReq</Name> <Rate>0</Rate> <LastMinRate>0</LastMinRate> <Counter>0</Counter> </FlowRater><FlowRater> <Name>Total.AcceptedReq</Name> <Rate>0</Rate> <LastMinRate>0</LastMinRate> <Counter>209</Counter> </FlowRater><FlowRater> <Name>Total.FailedSendResponse</Name> <Rate>0</Rate> <LastMinRate>0</LastMinRate> <Counter>0</Counter> </FlowRater><FlowRater> <Name>Total.RejectedRetry</Name> <Rate>0</Rate> <LastMinRate>0</LastMinRate> <Counter>0</Counter> </FlowRater><FlowRater> <Name>Total.IncomingRetry</Name> <Rate>0</Rate> <LastMinRate>0</LastMinRate> <Counter>0</Counter> </FlowRater><FlowRater> <Name>Total.RejectedLastRetry</Name> <Rate>0</Rate> <LastMinRate>0</LastMinRate> <Counter>0</Counter> </FlowRater></OverallConnectionPoolStatus>
      After reviewing your actual XML - it looks like your XPath is incorrect for your intentions. I don't see any attriubes in your XML.

      Try something more like //OverallConnectionPoolStatus/FlowRater/Name/text() to reference your information.

      The previous XPath's are attempting to search for attributes in the FlowRater node. What you actually have is a child node called Name with some information in it.

      As far as why this works in some modules, and not in others I would postulate that the designer included this as a "feature" to help others out. - Or maybe you found a bug.
        I still cant make it to work :(
        The xpath expression you suggested:
        //OverallConnectionPoolStatus/FlowRater/Name/text()
        Still makes Twig crash! Why? it is a valid xpath expression!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://757373]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (7)
As of 2020-11-30 23:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?