Search Results

Search found 803 results on 33 pages for 'xpath'.

Page 8/33 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • Get a single element with PHP and XPath

    - by daliz
    Lots of tutorials around the net but none of them can explain me this: How do I select a single element (in a table, for example), having its absolute XPath? Example: I have this: /html/body/table/tbody/tr[2]/td[2]/table/tbody/tr/td/table[3]/tbody/tr/td/table/tbody/tr[3]/td/table/tbody/tr[4]/td[5]/span What's that PHP function to get the text of that element?! Really I could not find an answer. Found lots of guides and hints to get all the elements of the table, all the buttons of a form, etc, but not what I need. Thank you.

    Read the article

  • XPath conditional text node selection

    - by Reinderien
    Hi there. I need to construct an xpath string to select all descendants of a certain table with these conditions: The table is a descendant of a form with a specific action attribute value. The selected descendants are text nodes. The text node content can only contain whitespace. It'll probably look something like: //form[@action = "submit.html"]//table//text()[ ...? ] Any tips would be appreciated. Thanks. Edit: For clarity, here is my current (working) compromise: function KillTextNodes(rootpath) { XPathIterate(rootpath + '//text()', function(node) { var tagname = node.parentNode.tagName; if (tagname != 'OPTION' && tagname != 'TH') Kill(node); }); }

    Read the article

  • PHP XPath - how to get value from result

    - by LeeTee
    I have the followng XML file from Ebay <GeteBayDetailsResponse xmlns="urn:ebay:apis:eBLBaseComponents"><Timestamp>2012-07-04T12:02:14.541Z</Timestamp><Ack>Success</Ack><Version>779</Version><Build>E779_INTL_BUNDLED_14986004_R1</Build><SiteDetails><Site>US</Site><SiteID>0</SiteID><DetailVersion>1</DetailVersion><UpdateTime>2009-07-09T10:48:17.000Z</UpdateTime></SiteDetails><SiteDetails><Site>Canada</Site><SiteID>2</SiteID><DetailVersion>1</DetailVersion><UpdateTime>2009-07-09T10:48:17.000Z</UpdateTime></SiteDetails><SiteDetails><Site>UK</Site><SiteID>3</SiteID><DetailVersion>1</DetailVersion><UpdateTime>2009-07-09T10:48:17.000Z</UpdateTime></SiteDetails><SiteDetails><Site>Germany</Site><SiteID>77</SiteID><DetailVersion>1</DetailVersion><UpdateTime>2009-07-09T10:48:17.000Z</UpdateTime></SiteDetails><SiteDetails><Site>Australia</Site><SiteID>15</SiteID><DetailVersion>1</DetailVersion><UpdateTime>2009-07-09T10:48:17.000Z</UpdateTime></SiteDetails><SiteDetails><Site>France</Site><SiteID>71</SiteID><DetailVersion>1</DetailVersion><UpdateTime>2009-07-09T10:48:17.000Z</UpdateTime></SiteDetails><SiteDetails><Site>eBayMotors</Site><SiteID>100</SiteID><DetailVersion>1</DetailVersion><UpdateTime>2009-07-09T10:48:17.000Z</UpdateTime></SiteDetails><SiteDetails><Site>Italy</Site><SiteID>101</SiteID><DetailVersion>1</DetailVersion><UpdateTime>2009-07-09T10:48:17.000Z</UpdateTime></SiteDetails><SiteDetails><Site>Netherlands</Site><SiteID>146</SiteID><DetailVersion>1</DetailVersion><UpdateTime>2009-07-09T10:48:17.000Z</UpdateTime></SiteDetails><SiteDetails><Site>Spain</Site><SiteID>186</SiteID><DetailVersion>1</DetailVersion><UpdateTime>2009-07-09T10:48:17.000Z</UpdateTime></SiteDetails><SiteDetails><Site>India</Site><SiteID>203</SiteID><DetailVersion>1</DetailVersion><UpdateTime>2009-07-09T10:48:17.000Z</UpdateTime></SiteDetails><SiteDetails><Site>HongKong</Site><SiteID>201</SiteID><DetailVersion>1</DetailVersion><UpdateTime>2009-07-09T10:48:17.000Z</UpdateTime></SiteDetails><SiteDetails><Site>Singapore</Site><SiteID>216</SiteID><DetailVersion>1</DetailVersion><UpdateTime>2009-07-09T10:48:17.000Z</UpdateTime></SiteDetails><SiteDetails><Site>Malaysia</Site><SiteID>207</SiteID><DetailVersion>1</DetailVersion><UpdateTime>2009-07-09T10:48:17.000Z</UpdateTime></SiteDetails><SiteDetails><Site>Philippines</Site><SiteID>211</SiteID><DetailVersion>1</DetailVersion><UpdateTime>2009-07-09T10:48:17.000Z</UpdateTime></SiteDetails><SiteDetails><Site>CanadaFrench</Site><SiteID>210</SiteID><DetailVersion>1</DetailVersion><UpdateTime>2009-07-09T10:48:17.000Z</UpdateTime></SiteDetails><SiteDetails><Site>Poland</Site><SiteID>212</SiteID><DetailVersion>1</DetailVersion><UpdateTime>2009-07-09T10:48:17.000Z</UpdateTime></SiteDetails><SiteDetails><Site>Belgium_Dutch</Site><SiteID>123</SiteID><DetailVersion>1</DetailVersion><UpdateTime>2009-07-09T10:48:17.000Z</UpdateTime></SiteDetails><SiteDetails><Site>Belgium_French</Site><SiteID>23</SiteID><DetailVersion>1</DetailVersion><UpdateTime>2009-07-09T10:48:17.000Z</UpdateTime></SiteDetails><SiteDetails><Site>Austria</Site><SiteID>16</SiteID><DetailVersion>1</DetailVersion><UpdateTime>2009-07-09T10:48:17.000Z</UpdateTime></SiteDetails><SiteDetails><Site>Switzerland</Site><SiteID>193</SiteID><DetailVersion>1</DetailVersion><UpdateTime>2009-07-09T10:48:17.000Z</UpdateTime></SiteDetails><SiteDetails><Site>Ireland</Site><SiteID>205</SiteID><DetailVersion>1</DetailVersion><UpdateTime>2009-07-09T10:48:17.000Z</UpdateTime></SiteDetails><UpdateTime>2009-07-09T10:48:17.000Z</UpdateTime></GeteBayDetailsResponse> I need to get the value of node SiteID where the node Site matches whatever variable I pass. The code I have is: $xml_file ='SiteDetails.xml'; $xmlDoc = new DomDocument(); $xmlDoc->load($xml_file); $xpath = new DOMXpath($xmlDoc); $siteIDList = $xpath->query("/GeteBayDetailsResponse/SiteDetails[Site=$site]/SiteID"); var_dump($siteIDList); echo $siteIDList->SiteID; I get the following result: object(DOMNodeList)#11 (0) { } Can anyone help? I want to get a value of 3.

    Read the article

  • XPath : finding an attribute node (and only one)

    - by subtenante
    What is the XPath to find only ONE node (whichever) having a certain attribute (actually I'm interested in the attribute, not the node). For example, in my XML, I have several tags having a lang attribute. I know all of them must have the same value. I just want to get any of them. Right now, I do this : //*[1][@lang]/@lang, but it seems not to work properly, for an unknown reason. My tries have led me to things ranging from concatenation of all the @lang values ('en en en en...') to nothing, with sometimes inbetween what I want but not on all XML. EDIT : Actually //@lang[1] can not work, because the function position() is called before the test on a lang attribute presence. So it always takes the very first element found in the XML. It worked best at the time because many many times, the lang attribute was on root element.

    Read the article

  • xslt and xpath: match preceding comments

    - by miasbeck
    given this xml: <root> <list> <!-- foo's comment --> <item name="foo" /> <item name="bar" /> <!-- another foo's comment --> <item name="another foo" /> </list> </root> I'd like to use a XPath to select all item-nodes that have a comment immediately preceding them, that is I like to select the "foo" and "another foo" items, but not the "bar" item. I already fiddled about the preceding-sibling axis and the comment() function but to no avail.

    Read the article

  • XPath 1.0 to find if an element's value is in a list of values

    - by user364902
    Is there a way to construct an XPath that evaluates whether an element's value is in a predefined list of values? Something akin to this: /Location/Addr[State='TX or AL or MA'] Which would match nodes whith State elements for Texas, Alabama, or Massachusetts? I know that I can unpack the expression: /Location/Addr[State='TX] or /Location/Addr[State='AL'], etc... But this is a bit cumbersome since the xpaths are quite long, as is the list of values. My google-fu isn't turning up much on the issue...

    Read the article

  • How to write a xpath to match all elements except a particular element

    - by Unmesh Kondolikar
    I am writing an XSL transformation. I want to write a template which matches all the child elements of the document except one particular node. My xml looks like this - <Document> <NodeA><\NodeA> <NodeB><\NodeB> <ServiceNode><\ServiceNode> <NodeX><\NodeX> </Document> I want to write a template that matches all nodes except ServiceNode i.e. NodeA to NodeX. How to write this Xpath to get - <xsl:template match="ALL Nodex Except ServiceNode">

    Read the article

  • xpath nearest element to a given element

    - by nologo
    hi, having trouble returning an element using xpath.. i need to get the text from the 2nd TD.. <tr> <td> <label for="PropertyA">Some text here </label> </td> <td> TEXT!! </td> </tr> i'm able to find the label element but then im having trouble selecting the td following to return the text. this is how i select the label: "//label[@for='PropertyA']" thanks

    Read the article

  • Improve XPath efficiency for repeated, parameterized queries

    - by Chris Allan
    Hi, I am repeatedly performing the following XPath query (though parameterized by 'keywordText') around 40,000 times: String query = SystemGlobal.YAHOO_KEYWORDSSUBNODE + "/" + SystemGlobal.YAHOO_KEYWORDNODE + "[" + SystemGlobal.YAHOO_ATTRKEYPHRASE + "='" + keywordText + "']"; CachedXPathAPI cachedXPathAPI = new CachedXPathAPI(); NodeIterator nl = cachedXPathAPI.selectNodeIterator(doc.getElementsByTagName(SystemGlobal.YAHOO_KEYWORDSROOT).item(0), query); Node n; if ((n = nl.nextNode()) != null) { keyword.setKeywordId(Long.parseLong(cachedXPathAPI.selectSingleNode(n, SystemGlobal.YAHOO_ATTRKEYID).getTextContent())); keyword.setKeyPhrase(cachedXPathAPI.selectSingleNode(n, SystemGlobal.YAHOO_ATTRKEYPHRASE).getTextContent()); keyword.setStatus(mapStatus(cachedXPathAPI.selectSingleNode(n, SystemGlobal.YAHOO_ATTRSTATUS).getTextContent())); keyword.setCampaignId(Long.parseLong(cachedXPathAPI.selectSingleNode(n, "../../" + SystemGlobal.YAHOO_ATTRCAMPAIGNID).getTextContent())); keyword.setAdGroupId(Long.parseLong(cachedXPathAPI.selectSingleNode(n, "../" + SystemGlobal.YAHOO_ATTRADGROUPID).getTextContent())); On the first run of the script, all 40,000 runs of this piece of code will have nl.nextNode() == null, and everything runs quite quickly. However, on the following runs, when nl.nextNode() != null, then things slow down a lot - this takes around an additional 40min to run (whereas the first run takes maybe 1 minute). Oh, and the doc is constructed like so: InputSource in = new InputSource(new FileInputStream(filename)); DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance(); dfactory.setNamespaceAware(true); doc = dfactory.newDocumentBuilder().parse(in); I tried including the following lines reportEvaluator = new XPathEvaluatorImpl(reportDoc); reportResolver = reportEvaluator.createNSResolver(reportDoc); and rather creating a NodeIterator, instead creating an XPathResult: XPathResult result = (XPathResult)reportEvaluator.evaluate(query, doc.getElementsByTagName(SystemGlobal.YAHOO_KEYWORDSROOT).item(0), reportResolver, XPathResult.UNORDERED_NODE_ITERATOR_TYPE, null); however this ran even slower Is there a way in which I can speed up the running of this script? I have seen references to precompiled queries, though I haven't seen many actual details. Also, as seen in the code, I am using CachedXPathAPI, though the benefit for this case is not so great. Any help is much appreciated! Chris Allan

    Read the article

  • Xpath that evaluates -all- attributes?

    - by Tres
    I maybe be trying to do something invalid here, but maybe someone smarter than me knows the correct syntax to solve my problem. Given: <group code="vehicle"> <line code="car"> <cell> <box code="price">1000.00</box> </cell> </line> <line code="car"> <cell code="sports"> <box code="price">500.00</box> </cell> </line> </group> If I use //*[@code="vehicle"]//*[@code="car"]//*[@code="price"], I will get both boxes returned (1000.00 and 500.00)--as expected but not what I want. Is there an xpath syntax that will evaluate against all nodes that have an attribute of @code rather than skipping it if it doesn't match with the end result being that I only get back the first box (price of 1000.00)? Like asking, choose the first node with @code and that @code must equal "vehicle", then choose the next node with @code and that @code must equal "car", then choose the next node with @code and @code must equal "price".

    Read the article

  • XPath expression for a phpBB forum

    - by Biff
    I'm writing a Greasemonkey script, and I wanted to change the text of a forum post on a phpBB2 forum by using XPath to select the body of the post that occurs after a certain username, but the whole thing is a giant mess of tables. <tr> <td> <span class="name"> <a> <b>username</b> </span> <span></span> </td> <td> <table> <tbody> <tr></tr> <tr></tr> <tr> <td> <span class="postbody">text of post</span> <span></span> </td> </tr> </tbody> </table> </td> </tr> I need to get the postbody span that happens after the username in the b tag equals a certain name, and then mess with the text.

    Read the article

  • Matching first set of elements with xpath...

    - by Ugo Enyioha
    I have an xml document that looks like this. <foo> <bar type="artist"/> Bob Marley </bar> <bar type="artist"/> Peter Tosh </bar> <bar type="artist"/> Marlon Wayans </bar> </foo> <foo> <bar type="artist"/> Bob Marley </bar> <bar type="artist"/> Peter Tosh </bar> <bar type="artist"/> Marlon Wayans </bar> </foo> <foo> <bar type="artist"/> Bob Marley </bar> <bar type="artist"/> Peter Tosh </bar> <bar type="artist"/> Marlon Wayans </bar> </foo> I would like to construct an xpath that returns only the first set: <bar type="artist"/> Bob Marley </a> <bar type="artist"/> Peter Tosh </a> <bar type="artist"/> Marlon Wayans </a> How would one go about this? I have tried //bar[@type='artist'] but it's obvious there's more to this. Thanks in advance.

    Read the article

  • Find position of a node within a nodeset using xpath

    - by Phil Nash
    After playing around with position() in vain I was googling around for a solution and arrived at this older stackoverflow question which almost describes my problem. The difference is that the nodeset I want the position within is dynamic, rather than a contiguous section of the document. To illustrate I'll modify the example from the linked question to match my requirements. Note that each <b> element is within a different <a> element. This is the critical bit. <root <a <bzyx</b </a <a <bwvu</b </a <a <btsr</b </a <a <bqpo</b </a </root Now if I queried, using XPath for a/b I'd get a nodeset of the four <b> nodes. I want to then find the position within that nodeset of the node that contains the string 'tsr'. The solution in the other post breaks down here: count(a/b[.='tsr']/preceding-sibling::*)+1 returns 1 because preceding-sibling is navigating the document rather than the context node-set. Is it possible to work within the context nodeset?

    Read the article

  • Navigating to nodes using xpath in flat structure

    - by James Berry
    I have an xml file in a flat structure. We do not control the format of this xml file, just have to deal with it. I've renamed the fields because they are highly domain specific and don't really make any difference to the problem. <attribute name="Title">Book A</attribute> <attribute name="Code">1</attribute> <attribute name="Author"> <value>James Berry</value> <value>John Smith</value> </attribute> <attribute name="Title">Book B</attribute> <attribute name="Code">2</attribute> <attribute name="Title">Book C</attribute> <attribute name="Code">3</attribute> <attribute name="Author"> <value>James Berry</value> </attribute> Key things to note: the file is not particularly hierarchical. Books are delimited by an occurance of an attribute element with name='Title'. But the name='Author' attribute node is optional. Is there a simple xpath statement I can use to find the authors of book 'n'? It is easy to identify the title of book 'n', but the authors value is optional. And you can't just take the following author because in the case of book 2, this would give the author for book 3. I have written a state machine to parse this as a series of elements, but I can't help thinking there would have been a way to directly get the results that I want.

    Read the article

  • Does XPath will return a object other than String

    - by Kalyan
    I have map xml as below. I can retrieve a value using XPath but can I retrieve object instead?. For example I want Map object to be retured if I say /list/* . Is it possible to retrieve as object. <list> <map> <val name="obj_type">USER</val> <val name="ret_name">user</val> <list name="attributes"> <map> <val name="obj_type">USER_ID</val> <val name="ret_name">userID</val> </map> <map> <val name="obj_type"> USER_UsernamePasswordCredential </val> <list name="attributes"> <map> <val name="obj_type">UNP_Username</val> <val name="ret_name">UserName</val> </map> <map> <val name="obj_type">UNP_Password</val> <val name="ret_name">Password</val> </map> </list> </map> </list> </map> </list>

    Read the article

  • Problem in using xpath with xslt having distinct values

    - by AB
    I have XML like, <items> <item> <products> <product>laptop</product> <product>charger</product> <product>Cam</product> </products> </item> <item> <products> <product>laptop</product> <product>headphones</product> <product>Photoframe</product> </products> </item> <item> <products> <product>laptop</product> <product>charger</product> <product>Battery</product> </products> </item> </items> and I am using xslt on it //can't change xpath as getting it from somewhere else <xsl:param name="xparameter" select="items/item[products/product='laptop' and products/product='charger']"></xsl:param> <xsl:template match="/"> <xsl:for-each select="$xparameter"> <xsl:for-each select="products/product[not(.=preceding::product)]"> <xsl:sort select="."></xsl:sort> <xsl:value-of select="." ></xsl:value-of>, </xsl:for-each> </xsl:for-each> </xsl:template> I want the output to be laptop charger cam Battery But I m not getting the result as I m expecting...distinct values is working fine ..something is getting wrong when I am adding that and claus

    Read the article

  • using xpath get the correct value in selectName

    - by Sangeeta
    Below I have written the code. I need help to get the right value in selectName. I am new to XPath. Basically with this code I am trying to achieve if employeeName = Chris I need to return 23549 to the calling function. Please help. Part of the code: public static string getEmployeeeID(string employeeName) { Cache cache = HttpContext.Current.Cache; string cacheNameEmployee = employeeName + "Tech"; if (cache[cacheNameEpm] == null) { XPathDocument doc = new XPathDocument(HttpContext.Current.Request.MapPath("inc/xml/" + SiteManager.Site.ToString() + "TechToolTip.xml")); XPathNavigator navigator = doc.CreateNavigator(); string selectName = "/Technologies/Technology[FieldName='" + fieldName + "']/EpmId"; XPathNodeIterator nodes = navigator.Select(selectName); if (nodes.Count > 0) { if (nodes.Current.Name.Equals("FieldName")) //nodes.Current.MoveToParent(); //nodes.Current.MoveToParent(); //nodes.Current.MoveToChild("//EpmId"); cache.Add(cacheNameEpm, nodes.Current.Value, null, DateTime.Now + new TimeSpan(4, 0, 0), System.Web.Caching.Cache.NoSlidingExpiration, CacheItemPriority.Default, null); } } return cache[cacheNameEpm] as string; } XML file <?xml version="1.0" encoding="utf-8" ?> <Employees> <Employee> <EName>Chris</EName> <ID>23556</ID> </Employee> <Employee> <EName>CBailey</EName> <ID>22222</ID> </Employee> <Employee> <EName>Meghan</EName> <ID>12345</ID> </Employee> </Employees> PLEASE NOTE:This XML file has 100 nodes. I just put 1 to indicate the structure.

    Read the article

  • Loading attribute in XPATH, problem

    - by Nguyen Quoc Hung
    I've got a question about loading attribute in XPATH. I write short XML code to test: <?xml version="1.0" encoding="iso-8859-1"?> <?xml-stylesheet type="text/xsl" href="testDate.xsl"?> <element attribute="1/1/2100"> Hung </element> My XSL code: <?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <!--Handle the document: set up HTML page--> <xsl:template match="/"> <html> <head> </head> <body> This is a test <xsl:value-of select="element@attribute"/> </body> </html> </xsl:template> </xsl:stylesheet> Why it produces an error when loading the stylesheet? Would you please help me explain this? Thank you

    Read the article

  • trouble finding element on page using xpath or css

    - by doneright
    Guys, I'm trying to write xpath or css to find/click on list element "All" based on known span(in this case SNG NAME below). On page, there are different lists Which can contain same list item called as "All". So we have to identify "All" based on span(in this case SNG NAME below) can someone shed some light on my issue <html> <head> <body> <div class="grc_selected"> <div class ="lbl_selected"> <span> SNG NAME </span> </div> <div id="id1" class="cl1"> <ul id="id_ul"> <li class="tclass" title="[1] All"> <img class="treeIcon" src="1/2/3.gif"/> <span class="inA">All</span> </li> </ul> </div> </body> </head> </html>

    Read the article

  • XPath expression exception

    - by fftoolbar
    Hi I am not really sure if i am doing this right with XPath expression. I am trying to locate a text on DOM and this text is assingned to a variable. I have text stored in SQLite and i have retrievd the text and i am trying to locate it on the webpage which actually contains the text. so i ahve the following code: var searchText = dataset[x]['selectedText']; alert(dataset[x]['selectedText']); var res = googbar_frames[0].contentDocument.evaluate("//*[.=searchText]",googbar_frames[0].contentDocument.body,null,XPathResult.ANY_TYPE,null); alert(res.snapshotLength); And i get the following error. Error: Permission denied for <http://en.wikipedia.org> to call method XPathException.toString on <>. Error: Permission denied for <http://en.wikipedia.org> to call method XPathException.toString on <>. Have got the expression correct. I am trying to look for the text on DOM. Or am i going wrong somwehere? cheers

    Read the article

  • Accessing the value of an input element with XPath in an XSLT

    - by asymmetric
    Hi! I'm developing a web app that has a button that triggers an XSLT transformation of the document DOM, with a stylesheet fetched via AJAX. Here's a portion of the HTML: <html> <head> <title>Static Javascript-based XMR Form Creator</title> </head> <body> <h1 id="title">Static Javascript-based XMR Form Creator</h1> <div class="opt_block" id="main_opts"> Form name <input type="text" id="form_name" /> Form cols <input type="text" id="form_cols" size="3" maxlength="3" /> </div> <button id="generate">Generate source</button> <textarea rows="20" cols="50" id="xmr_source" ></textarea> </body> Inside the stylesheet, I want to access the value attribute of the first input field, the one with id form_name. The XSLT looks like this: <xsl:template match="/html/body/div[@id = 'main_opts']" > <form> <xsl:attribute name="fname"> <xsl:value-of select="input[@id = 'form_name']/@value" /> </xsl:attribute> </form> </xsl:template> The problem is that the XPath that should do the work: <xsl:value-of select="input[@id = 'form_name']/@value" /> returns nothing. Can anyone help?

    Read the article

  • Need help with an xpath query!

    - by gerrod
    Can anyone help with the following XPath question? Given the node-set: <table> <rows> <row> <value column="Product">Coal</value> <value column="Quantity">10000</value> </row> <row> <value column="Product">Iron</value> <value column="Quantity">5000</value> </row> <row> <value column="Product">Ore</value> <value column="Quantity">4000</value> </row> </rows> </table> I want to query to find the node sub-set with a given product name. Note that the product name is being supplied by an attribute of the current node being processed (i.e. "@name"). So when the @name attribute has the value of "Coal" I would expect this to be returned: <row> <value column="Product">Coal</value> <value column="Quantity">10000</value> </row> This is what I've come up with; I know it's wrong, because I don't get anything back. $table/rows/row[value[@column='Product'][text()=@name]] </code>

    Read the article

  • Problem in using xpath with xslt having distint values

    - by AB
    I have XML like, <items> <item> <products> <product>laptop</product> <product>charger</product> <product>Cam</product> </products> </item> <item> <products> <product>laptop</product> <product>headphones</product> <product>Photoframe</product> </products> </item> <item> <products> <product>laptop</product> <product>charger</product> <product>Battery</product> </products> </item> </items> and I am using xslt on it //can't change xpath as getting it from somewhere else <xsl:param name="xparameter" select="items/item[products/product='laptop' and products/product='charger']"></xsl:param> <xsl:template match="/"> <xsl:for-each select="$xparameter"> <xsl:for-each select="products/product[not(.=preceding::product)]"> <xsl:sort select="."></xsl:sort> <xsl:value-of select="." ></xsl:value-of>, </xsl:for-each> </xsl:for-each> </xsl:template> I want the output to be laptop charger cam Battery But I m not getting the result as I m expecting...distinct values is working fine ..something is getting wrong when I am adding that and claus

    Read the article

  • XPath Query - Select relative top level nodes

    - by John
    I'm trying to iterate over some elements in an XML document that may be nested, but as I iterate over them I may be removing some from the tree. I'm thinking the best way is to do this recursively, so I'm trying to come up with an XPath Query that will select all the top-level nodes relative to the current node. //foo[not(ancestor::foo)] works great at the document level, but I'm trying to figure out how to do this from a relative query. <foo id="1"> <foo id="2" /> <foo id="3"> <foo id="4"> <bar> <foo id="5"> <foo id="6" /> </foo> <foo id="7" /> </bar> </foo> </foo> </foo> If the current node is foo#3, I only want to select foo#4. When the current node is foo#4, I only want to select foo#5 and foo#7. I think I'm trying to select any descendant foo nodes of the current node, but without any ancestor foo nodes between the current node and the node I'm selecting. My conundrum is if we're already inside a foo node, not(ancestor::foo) doesn't help.

    Read the article

  • Add two hexBinarys with XPATH 1.0

    - by fielding
    Hi, my xml document looks somewhat like that (Values are both xsl:hexBinary): <Offsets> <Offset> <Name>ErrorOffset</Name> <Value>DD</Value> </Offset> <Offset> <Name>OtherOffset</Name> <Value>FF</Value> </Offset> </Offsets> <Value> <Name>Error1</Name> <Code>01</Code> </Value> <Value> <Name>Error2</Name> <Code>02</Code> <Offset>ErrorOffset</Offset> </Value> now i want to transform this to a new xml file: <Value> <Name>Error1</Name> <Code>01</Code> </Value> <Value> <Name>Error2</Name> <Code>DF</Code> </Value> All that should happen is adding <Offset> to the basic <Value>. But plain + returns NaN and sum() expects only one parameter. XSLT and XPATH are quite nice, but it goes on my nerves that easy operations like adding two hex values just dont work as easy as it should.

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >