Search Results

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

Page 13/33 | < Previous Page | 9 10 11 12 13 14 15 16 17 18 19 20  | Next Page >

  • Namespace Traversal

    - by RikSaunderson
    I am trying to parse the following sample piece of XML: <?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soapenv:Body> <d2LogicalModel modelBaseVersion="1.0" xmlns="http://datex2.eu/schema/1_0/1_0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://datex2.eu/schema/1_0/1_0 http://datex2.eu/schema/1_0/1_0/DATEXIISchema_1_0_1_0.xsd"> <payloadPublication xsi:type="PredefinedLocationsPublication" lang="en"> <predefinedLocationSet id="GUID-NTCC-VariableMessageSignLocations"> <predefinedLocation id="VMS30082775"> <predefinedLocationName> <value lang="en">VMS M60/9084B</value> </predefinedLocationName> </predefinedLocation> </predefinedLocationSet> </payloadPublication> </d2LogicalModel> </soapenv:Body> </soapenv:Envelope> I specifically need to get at the contents of the top-level predefinedLocation tag. By my calculations, the correct XPath should be /soapenv:Envelope/soapenv:Body/d2LogicalModel/payloadPublication/predefinedLocationSet/predefinedLocation I am using the following C# code to parse the XML: string filename = "content-sample.xml"; XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(filename); XmlNamespaceManager nsmanager = new XmlNamespaceManager(xmlDoc.NameTable); nsmanager.AddNamespace("soapenv", "http://schemas.xmlsoap.org/soap/Envelope"); string xpath ="/soapenv:Envelope/soapenv:Body/d2LogicalModel/payloadPublication/predefinedLocationSet/predefinedLocation"; XmlNodeList itemNodes = xmlDoc.SelectNodes(xpath, nsmanager); However, this keeps coming up with no results. Can anyone shed any light on this, because I feel like I'm banging my head on a brick wall.

    Read the article

  • XML parsing problem

    - by Albinoswordfish
    I'm having this strange XML parsing problem. I have this XML string I'm trying to parse <?xml version="1.0"?> <response status="success"> <lot>32342</lot> </response> I'm using XPath with Java in order to do this. I'm using the Xpath expression "/response/@status" to find the text "success". However whenever I evaluate this expression I get an empty string. However I am able to successfully parse this string using "/response/@type" <?xml version="1.0"?> <response type="success"> <lot>32342</lot> </response> So why would simply changing the name of the attribute change the return string to nothing? is = new InputSource(testWOcreateStrGood); xPathexpressionSuccess = xPath.compile("/response/@status"); responseStr = xPathexpressionSuccess.evaluate(is); reponseStr is the string I posted earlier with the "status" attribute

    Read the article

  • Unable to get node using xpath in soapUI

    - by R.S
    How can i access "AccountId" node from following response file using Xpath in soapUI 4.0.0? Thanks in advance. Response file is as follow, <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Body> <GetResponse xmlns="http://www.tieto.com/cmw/tcm/account"> <GetResult xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <Account> <AccountId>14338049839</AccountId> <AccountLabel>Spara Femman</AccountLabel> <AccountRoleDTOList> <AccountRole> <AddressTypeId>REC</AddressTypeId> <EndDay i:nil="true"/> <ExtPosReference i:nil="true"/> <HolderId>10533</HolderId> <HolderName>TÄRNHOLMS HOTELL AB</HolderName> <HolderTypeId>COR</HolderTypeId> <IdentificationId>005164006917</IdentificationId> <ReportProfileId>3</ReportProfileId> <ReportProfileName>Standard</ReportProfileName> <RoleDocumentPath i:nil="true"/> <RoleId>HOL</RoleId> <RoleName>Holder</RoleName> <ShareOfAccount>100.00000</ShareOfAccount> </AccountRole> </AccountRoleDTOList> <AccountTypeId>AGG</AccountTypeId> <CloseDay i:nil="true"/> <CurrencyId>SEK</CurrencyId> <CustodianAccountId i:nil="true"/> I have tried it by using following code... but it's not working declare namespace i='http://www.w3.org/2001/XMLSchema-instance'; //i:GetResult[1]/Account[1] But i am getting error like, Missing content for xpath declare namespace i='http://www.w3.org/2001/XMLSchema-instance'; //i:GetResult[1]/Account[1] in response

    Read the article

  • C# XPath id() not working?

    - by Iggyhopper
    I'm using C# and I'm stumped. Does it just not support id()? I have a large XML file, about 4-5 of them at ~400kb, so I need some speed and performance wherever I can get it. I use XmlDocument.SelectSingleNode("id('blahblahblah')") and it doesn't get the node by id. Am I going crazy or is it that C# XPath just doesn't support id()?

    Read the article

  • Forming Xpath Query for total Google results

    - by user619879
    I've used this formula in Google Spreadsheets in the past to input the number of search results into a cell. The formula's not working anymore and I know I need to fix the xpath query. any ideas? Current formula: =importXML("http://www.google.com/search?num=100&q="&A2,"//p[@id='resultStats']/b[3]") Spreadsheet for public testing: https://spreadsheets8.google.com/ccc?key=tJzmFllp7Sk1lt23cXSVXFw&authkey=CM625OUO#gid=0

    Read the article

  • ruby yaml ypath like xpath ?

    - by gurpal2000
    Hi i have a yaml file like so --- data: - date: "2004-06-11" description: First description - date: "2008-01-12" description: Another descripion How can i do a "ypath" query similar to xpath for xml ? Something like "get the description where the date is 2004-06-11" YAML.parse_file('myfile.yml').select('/data/*/date == 2004-06-11') How do you do it, and if that's possible how can i similarly edit the description by 'ypath' ? Thanks

    Read the article

  • xforms "instance namespace" issue

    - by user302254
    I am creating an Xform that reads an XML document and creates an input form for updating the document. However, apparently due to a namespace issue none of my Xpath expressions resolve.My form works fine on a simple instance when the instance file has no namespace. However, I need the namespace support. My instance file has a namespace "ai:inventory." I am referencing the instance data Where should I be declaring the prefix "ai" for my namespace so that my XPath expressions can find the appropriate elements? /ai:inventory/products ? I've tried creating the prefix in the html opening tag... that didn't help. thanks,

    Read the article

  • RETRIVE XPATH OF AN XML ELELEMNT BY USING ITS VALUE

    - by user299938
    My XmlFile looks like this: <?xml version="1.0"?> <document-inquiry> <publication-reference data-format="docdb" xmlns="http://www.epo.org/exchange"> <document-id> <country>EP</country> <doc-number>2160088</doc-number> <kind>A1</kind> </document-id> </publication-reference> </document-inquiry> For the above xml i need to get the xpath of a specific element say for example "country element" as My Output: "/document-inquiry/publication-reference/document-id/country" My Input : By using its value "EP" This is the code i tried doc.SelectSingleNode("/document-inquiry/publication-reference/document-id[text()='EP']"); I receivev null for the above code. I have to get it using the c# code. Can anyone pls help me on this

    Read the article

  • help with xpath selecting

    - by fayer
    i've got an id attribute value for an element. i want to select only its children (not all descendants). i used $childElements = $xml-xpath('//entity[@id=212323]'); print_r($childElements); but that would select ALL descendants and print them out. i just want to select the 1 generation children. how could i do that? <entity id=212323> <this>asd</this> <this>asd</this> <this>asd</this> <this> <notThis>asd</notThis> <notThis>asd</notThis> <notThis>asd</notThis> </this> </entity>

    Read the article

  • XSL: How to print an iterated node in for-each

    - by Shoaib
    xml: <skills> <skill>PHP</skill> <skill>CSS</skill> <skill>HTML</skill> <skill>XML</skill> </skills> XSL: <ul> <xsl:for-each select="skills/skill"> <li><xsl:value-of select="[what should be xpath here]" /></li </xsl:for-each> </ul> Here what should be the xpath to print each skill?

    Read the article

  • HTML Agility Pack Screen Scraping XPATH isn't returning data

    - by Matthias Welsh
    I'm attempting to write a screen scraper for Digikey that will allow our company to keep accurate track of pricing, part availability and product replacements when a part is discontinued. There seems to be a discrepancy between the XPATH that I'm seeing in Chrome Devtools as well as Firebug on Firefox and what my C# program is seeing. The code I'm currently using is pretty quick and dirty... //This function retrieves data from the digikey private static List<string> ExtractProductInfo(HtmlDocument doc) { List<HtmlNode> m_unparsedProductInfoNodes = new List<HtmlNode>(); List<string> m_unparsedProductInfo = new List<string>(); //Base Node for part info string m_baseNode = @"//html[1]/body[1]/div[2]"; //Write part info to list m_unparsedProductInfoNodes.Add(doc.DocumentNode.SelectSingleNode(m_baseNode + @"/table[1]/tr[1]/td[1]/table[1]/tr[1]/td[1]")); //More lines of similar form will go here for more info //this retrieves digikey PN foreach(HtmlNode node in m_unparsedProductInfoNodes) { m_unparsedProductInfo.Add(node.InnerText); } return m_unparsedProductInfo; } Although the path I'm using appears to be "correct" I keep getting NULL when I look at the list "m_unparsedProductInfoNodes" Any idea what's going on here? I'll also add that if I do a "SelectNodes" on the baseNode it only returns a div... not sure what that indicates but it doesn't seem right.

    Read the article

  • Preserving order when copying elements using Deliverance / XPath

    - by Jon Hadley
    How would I, using Deliverance & XPath (or CSS) selectors, select and copy list items .one and .three from each list below, but display them in the order of their parent list? <ul id="a-wrapper"> <li class="one"></li> <li class="two"></li> <li class="three"></li> <li class="four"></li> </li> <ul id="b-wrapper"> <li class="one"></li> <li class="two"></li> <li class="three"></li> <li class="four"></li> </ul> c,d,e,f,g etc.... The catch is it needs to use a href rule, eg: <prepend href="/blah/deblah" content="#x" theme="#y" /> Using the following just lists all the .one elements, then all the .three elements. <prepend href="/blah/deblah" content=".one" theme="#y" /> <prepend href="/blah/deblah" content=".three" theme="#y" />

    Read the article

  • xpath evaluting error in andorid

    - by R_Dhorawat
    i'm running one application in android browser which contain the following code.. [ if (typeof XPathResult != "undefined") { //use build in xpath support for Safari 3.0 //alert("xpathExpr"+xpathExpr); //alert("doc"+doc); var xmlDocument = doc; if (doc.nodeType != 9) { xmlDocument = doc.ownerDocument; } results = xmlDocument.evaluate(xpathExpr,doc, function(prefix) { return namespaces[prefix] || null;}, XPathResult.ANY_TYPE, null ); var thisResult; result = []; var len = 0; do { thisResult = results.iterateNext(); if (thisResult) { result[len] = thisResult; len++; } } while ( thisResult ); } else { try{ if (doc.selectNodes) { result = doc.selectNodes(xpathExpr); } }catch(ex){} } return result; ] but when i run this app in Firefox control come in if statement and everything works fine.. but in android browser it's giving error ... XPathResult undefined... this time control come to else statement and even here it's showing that selectNodes is undefind and. so the result come as null whereas in Firefox it's giving list of nodes.. realy need it to be done ... help needed.. thanks...

    Read the article

  • Searching in XML using Xpath

    - by Sathish
    I have an XML file like below , using xpath and xnavigator how can get the Value of the supplied Tag Attribute for example if i supply RangeName i should get AssumptClient <Validations> <FieldInfo id="1"> <Name>OMID</Name> <Mandatory>Yes</Mandatory> <RangeName>AssumptOMID</RangeName> <DataType>int</DataType> <MaxLength>10</MaxLength> </FieldInfo> <FieldInfo id="2"> <Name>ClientName</Name> <Mandatory>Yes</Mandatory> <RangeName>AssumptClient</RangeName> <DataType>string</DataType> <MaxLength>50</MaxLength> </FieldInfo> <FieldInfo id="3"> <Name>OppName</Name> <Mandatory>Yes</Mandatory> <RangeName>AssumptProjectName</RangeName> <DataType>string</DataType> <MaxLength>50</MaxLength> </FieldInfo> <FieldInfo id="4"> <Name>OperatingGroup</Name> <Mandatory>Yes</Mandatory> <RangeName>AssumptOperatingGroup</RangeName> <DataType>string</DataType> <MaxLength>50</MaxLength> </FieldInfo> </Validations> for now i am using the below code XPathDocument doc; XPathNavigator nav; XPathExpression expr; XPathNodeIterator iterator; doc = new XPathDocument(strConfigFile); nav = doc.CreateNavigator(); expr = nav.Compile("/configuration/Validations/FieldInfo[RangeName='AssumptClient']"); iterator = nav.Select(expr); if (iterator.MoveNext()) { XPathNavigator nav2 = iterator.Current.Clone(); textBox1.Text = nav2.GetAttribute("RangeName", ""); }

    Read the article

  • Parse html and find data in the html

    - by Dan.StackOverflow
    Hi all. I am trying to use html5lib to parse an html page in to something I can query with xpath. html5lib has close to zero documentation and I've spent too much time trying to figure this problem out. Ultimate goal is to pull out the second row of a table: <html> <table> <tr><td>Header</td></tr> <tr><td>Want This</td></tr> </table> </html> so lets try it: >>> doc = html5lib.parse('<html><table><tr><td>Header</td></tr><tr><td>Want This</td> </tr></table></html>', treebuilder='lxml') >>> doc <lxml.etree._ElementTree object at 0x1a1c290> that looks good, lets see what else we have: >>> root = doc.getroot() >>> print(lxml.etree.tostring(root)) <html:html xmlns:html="http://www.w3.org/1999/xhtml"><html:head/><html:body><html:table><html:tbody><html:tr><html:td>Header</html:td></html:tr><html:tr><html:td>Want This</html:td></html:tr></html:tbody></html:table></html:body></html:html> LOL WUT? seriously. I was planning on using some xpath to get at the data I want, but that doesn't seem to work. So what can I do? I am willing to try different libraries and approaches.

    Read the article

  • XML parse node value as string

    - by bharathi
    My xml file is look like this . I want to get the value node text content as like this . <property regex=".*" xpath=".*"> <value> 127.0.0.1 </value> <property regex=".*" xpath=".*"> <value> val <![CDATA[ <Valve className="org.tomcat.AccessLogValve" exclude="PASSWORD,pwd,pWord,ticket" enabled="true" serviceName="zohocrm" logDir="../logs" fileName="access" format="URI,&quot;PARAM&quot;,&quot;REFERRER&quot;,TIME_TAKEN,BYTES_OUT,STATUS,TIMESTAMP,METHOD,SESSION_ID,REMOTE_IP,&quot;INTERNAL_IP&quot;,&quot;USER_AGENT&quot;,PROTOCOL,SERVER_NAME,SERVER_PORT,BYTES_IN,ZUID,TICKET_DIGEST,THREAD_ID,REQ_ID"/> ]]> test </value> </property> I want to get text as order they specified in a file . Here is my java code . Document doc = parseDocument("properties.xml"); NodeList properties = doc.getElementsByTagName("property"); for( int i = 0 , len = properties.getLength() ; i < len ; i++) { Element property = (Element)properties.item(i); //How can i proceed further . } Output Expected : Node 1 : 127.0.0.1 Node 2 : val <Valve className="org.tomcat.AccessLogValve" exclude="PASSWORD,pwd,pWord,ticket" enabled="true" serviceName="zohocrm" logDir="../logs" fileName="access" format="URI,&quot;PARAM&quot;,&quot;REFERRER&quot;,TIME_TAKEN,BYTES_OUT,STATUS,TIMESTAMP,METHOD,SESSION_ID,REMOTE_IP,&quot;INTERNAL_IP&quot;,&quot;USER_AGENT&quot;,PROTOCOL,SERVER_NAME,SERVER_PORT,BYTES_IN,ZUID,TICKET_DIGEST,THREAD_ID,REQ_ID"/> test Please suggest your views .

    Read the article

  • extract specific element from nested elements using lxml html

    - by Dan.StackOverflow
    Hi all I am having some problems that I think can be attributed to xpath problems. I am using the html module from the lxml package to try and get at some data. I am providing the most simplified situation below, but keep in mind the html I am working with is much uglier. <table> <tr> <td> <table> <tr><td></td></tr> <tr><td> <table> <tr><td><u><b>Header1</b></u></td></tr> <tr><td>Data</td></tr> </table> </td></tr> </table> </td></tr> </table> What I really want is the deeply nested table, because it has the header text "Header1". I am trying like so: from lxml import html page = '...' tree = html.fromstring(page) print tree.xpath('//table[//*[contains(text(), "Header1")]]') but that gives me all of the table elements. I just want the one table that contains this text. I understand what is going on but am having a hard time figuring out how to do this besides breaking out some nasty regex. Any thoughts?

    Read the article

  • XSLT 1.0 : Iterate over characters in a string

    - by subtenante
    I need to iterate over the characters in a string to build an XML structure. Currently, I am doing this : <xsl:template name="verticalize"> <xsl:param name="text">Some text</xsl:param> <xsl:for-each select="tokenize(replace(replace($text,'(.)','$1\\n'),'\\n$',''),'\\n')"> <xsl:element name="para"> <xsl:value-of select="."/> </xsl:element> </xsl:for-each> </xsl:template> This produces something like : <para>S</para> <para>o</para> <para>m</para> <para>e</para> <para> </para> <para>t</para> <para>e</para> <para>x</para> <para>t</para> This works fine with Xpath 2.0. But I need to apply the same treatment in a XPath 1.0 environment, where the replace() method is not available. Do you know a way to achieve this ?

    Read the article

  • How can I create/update an XML node that may or may not exist?

    - by ScottBai
    Is there a method available (i.e. without me creating my own recursive method), for a given xpath (or other method of identifying the hierarchical position) to create/update an XML node, where the node would be created if it does not exist? This would need to create the parent node if it does not exist as well. I do have an XSD which includes all possible nodes. i.e. Before: <employee> <name>John Smith</name> </employee> Would like to call something like this: CoolXmlUpdateMethod("/employee/address/city", "Los Angeles"); After: <employee> <name>John Smith</name> <address> <city>Los Angeles</city> </address> </employee> Or even a method to create a node, given an xpath, wherein it will recursively create the parent node(s) if they do not exist? As far as the application (if it matters), this is taking an existing XML doc that contains only populated nodes, and adding data to it from another system. The new data may or may not already have values populated in the source XML. Surely this is not an uncommon scenario?

    Read the article

  • Find element all of whose children have a given value

    - by cru3l
    for example, i have this xml <elements> <a> <b>6</b> <b>5</b> <b>6</b> </a> <a> <b>5</b> <b>5</b> <b>6</b> </a> <a> <b>5</b> <b>5</b> <b>5</b> <b>5</b> </a> </elements> i need a xpath query, which must return me parent tag, only if all its children are equal to 5 (a[3] in this case). Something like that //b[text()="5"]/.. but with check of all children's tags. Please note that number of children tags can be different from node to node. It's possible with only xpath query? thanks

    Read the article

  • How to get XML nodes content when names include special Characters?

    - by paoloi
    Im trying to navigate an XML block similar to this one ($doc) using PHP simplexml_load_string and using xpath on $doc to get only the 'Day' block like this: $myday = $doc->xpath ('//Day'); that lets me access all data from the block as an object, meaning $doc-AdultCount returns 1 and $doc-Id returns "6a0" however I can't access "SpecialDeals" content not using: $doc-SpecialDeals nor using: $doc-SpecialDeals-a:string Whats is the right syntax in this case? Thanks in advance. <Days> <DaysId>687</DaysId> <Day> <AdultsCount>1</AdultsCount> <Availability>Available</Availability> <Id>6a0</Id> <RoomType>Studio</RoomType> <SpecialDeals xmlns:a="http://microsoft.com/2003/Arrays"> <a:string>Best Day Ever</a:string> </SpecialDeals> </Day> <DaysPrice>247.4</DaysPrice> </Days>");

    Read the article

  • How to get attribute value using SelectSingleNode?

    - by Nano HE
    I am parsing a xml document, I need find out the gid (an attribute) value (3810). Based on SelectSingleNode(). I found it is not easy to find the attribute name and it's value. Can I use this method or I must switch to other way. Attached my code. How can I use book obj to get the attribute value3810 for gid. Thank you. My test.xml file as below <?xml version="1.0" ?> <root> <VersionInfo date="2007-11-28" version="1.0.0.2" /> <Attributes> <AttrDir name="EFEM" DirID="1"> <AttrDir name="Aligner" DirID="2"> <AttrDir name="SequenceID" DirID="3"> <AttrObj text="Slot01" gid="3810" unit="" scale="1" /> <AttrObjCount value="1" /> </AttrDir> </AttrDir> </AttrDir> </Attributes> </root> I wrote the test.cs as below public class Sample { public static void Main() { XmlDocument doc = new XmlDocument(); doc.Load("test.xml"); XmlNode book; XmlNode root = doc.DocumentElement; book = root.SelectSingleNode("Attributes[AttrDir[@name='EFEM']/AttrDir[@name='Aligner']/AttrDir[@name='SequenceID']/AttrObj[@text='Slot01']]"); Console.WriteLine("Display the modified XML document...."); doc.Save(Console.Out); } } [Update 06/10/2010] The xml file is a complex file. Included thousands of gids. But for each of Xpath, the gid is unique. I load the xml file to a TreeView control. this.treeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterSelect);. When treeView1_AfterSelect event occurred, the e.Node.FullPath will return as a String Value. I parse the string Value e.Node.FullPath. Then I got the member of XPath Above. Then I tried to find which gid item was selected. I need find the gid value as a return value indeed.

    Read the article

< Previous Page | 9 10 11 12 13 14 15 16 17 18 19 20  | Next Page >