xpath

Removing a node from xml file

I have an xml file <?xml version="1.0"?> <category> <name>SWEATERS</name> <name>WATCHES</name> <name>PANTS</name> <name>test</name> <name>1</name> </category> How i can remove the node <name>test</name> using xpath ,xquery and php. I used this code $name='test; $xmlfile="config/shop_categories.xml"; $xml = simple...

PHP: Fetch content from a html page using xpath()

I'm trying to fetch the content of a div in a html page using xpath and domdocument. This is the structure of the page: <div id="content"> <div class="div1"></div> <span class="span1></span> <p></p> <p></p> <p></p> <p></p> <p></p> <div class="div2"></div> </div> I want to get only the content of p, not spans and divs. I came thru this...

XSLT: select a node who starts with a predefined list of elements

Hi, We have in input an XML like following: <R> <MT N="folder" V="Folder1\Subfolder1" /> <MT N="folder" V="Folder2xx\Subfolder1" /> <MT N="folder" V="Folder3yyyy\Subfolder1" /> <MT N="folder" V="Folder4zzzz\Subfolder1" /> </R> In our XSLT that performs the display, the entry: <xsl:value-of select="MT[@N='folder']/@V"/> ...

Parsing simple XML with Nokogiri

Let's say I have the following XML : <links> <item> <title>Title 1</title> <url>http://www.example.com/url-1&lt;/url&gt; </item> <item> <title>Title 2</title> <url>http://www.example.com/url-2&lt;/url&gt; </item> <item> <title>Title 3</title> <url>http://www.example.com/url-3&lt;/url&gt; </item> </l...

How to use XPath on xml docs having default namespace

I want to manipulate xml doc having default namespace but no prefix. Is there a way to use xpath without namespace uri just as if there is no namespace? I believe it should be possible if we set namespaceAware property of documentBuilderFactory to false. But in my case it is not working. Is my understanding is incorrect or I am doing som...

c# parse html using XPathDocument

hi all! i'm trying to parse an html page with XPathDocument, but gives error 'cause the html is not an xml... is there a way to do this or not? ...

How to get HTML tables using xpath in c?

I'm using libxml2 in my c project. I was wondering how could I grab all tables in a html file using xpath. Sample code will do the trick. I need to parse the data in html table. Thanks EDIT: This is a row of the table: <tr class="report-data-row-even"> <td class="NormalTxt report-data-cell report-data-column-even"><nobr>0.0285</nob...

How to extract all occurences of a specific tags of an xaml/xml file?

Let's say I need to extract all solid-brushes and linear-gradient brushes in a dictionary resource file using C#. How can I do it? Please help! This question can be extended to be more general like "How to find the multiple-lines match(es) when searching a file using C#?" ...

Extract content with XPath?

I have html content that I am storing as an XML document (using HTML Agility Pack). I know some XPath, but I am not able to zero into the exact content I need. In my example below, I am trying to extract the "src" and "alt" text from the large image. This is my example: <html> <body> .... <div id="large_image_display"> <img...

XPATH returning no results

I have an loaded some XML in an XMLDocument object. I am iterating through the document by using an For Each node As XmlNode In doc.GetElementsByTagName("Item", [NAMESPACE]) 'Do Stuff Next I would like to use xpath within this loop to pull out all nodes with the name of "MyNode" I would have thought i would simply have to do node....

Help extracting text from HTML table using xpath

I'm trying to pull the text between the nobr tags. This is part of the table: <table class="report-main-table dirLTR NormalTxt" width="100%" border="0" cellspacing="0" cellpadding="0"> <thead> <tr> <td class="report-data-title-cell report-data-column-odd"><nobr><b>&#1505;&#1492;"&#1499; &#1506;&#1500;&#1493;&#1514; &#1489;&#1...

How to identify subtly different HTML anchor tags with XPath?

I have two anchor tags that differ only because the second one does not contain the word "Report" in the anchor text or in the address link. <a href="http://www.example.com/data/invoices/2010/10/invoices-report---tuesday-october-12.html"&gt;Invoices Report - Tuesday, October 12</a> <a href="http://www.example.com/data/invoices/2010/10/...

Help in parsing XML, simple string - but I can't seem to parse it

I have the following XML: <iq xmlns="jabber:client" to="[email protected]/agsXMPP" xml:lang="en" id="sub23" from="search.google.com" type="result"> <pubsub xmlns="http://jabber.org/protocol/pubsub"&gt; <subscription subscription="subscribed" subid="5077774B57777BD77770" node="search" jid="3985077777...

Deserialize custom SOAP/XML to objects

Hello, i have this xml/soap from a sharepoint webservice call: <GetAllUserCollectionFromWeb xmlns="http://schemas.microsoft.com/sharepoint/soap/directory/"&gt; <Users> <User ID="ID" Sid="ID" Name="XXX" LoginName="XXX" Email="XXX" Notes="" IsSiteAdmin="False" IsDomainGroup="False" Flags="0" /> <User ID="ID" Sid="ID" Name="XXX" ...

How do I choose parent node attribute and its child values using XML and Xquery?

I have this: <pss> <ps n="А parent node" m="654564654" t="435,8551" a="2857,2716"> <sc s="a1" a="25,4220"/> <sc s="a2" a="0"/> <sc s="a3" a="2395,9945"/> </ps> ... </pss> I need to select "А parent node m attribute and a1-a2 a values in one query. i tried this but it doesnt work: SELECT ps.value('@m', 'nvarchar(50)...

How to parse author name and book title from scraped HTML using XPath?

The HTML you see below is text I have scraped from a remote site, as-is, into a local variable. Now I need to parse the authorName and bookTitle from the HTML tags into their own variables, given the following consistent format of the scraped text: <p> William Faulkner - 'Light In August' <br/> William Faulkner - 'Sanctuary' <...

Using compound XPath Predicates to search XML message

I'm having trouble figuring out how to select data using a compound XPath query so that I can essentially find the 5th column of row in my data. Here is my example XML: <sample> <OBX> <field position="1">1</field> <field position="2">My Value</field> </OBX> <OBX> <field position="1">2</field> <field position="2">My other...

What is the difference between <xsl:apply-templates /> and <xsl:apply-templates select="." />

What is the difference between <xsl:apply-templates /> and <xsl:apply-templates select="." />. I thought that the select="." was not necessary, but I am getting different results depending on which I use. Sorry if this is a repeat. I have tried searching this issue but could not find anything. ...

How to get required XML element from not well formed XML data in SQL server

Hello, In my SQL 2008 database table, I have one column name AUTHOR that contains XML data. The XML is not well formed and has data like below <Author> <ID>172-32-1176</ID> <LastName>White</LastName> <FirstName>Johnson</FirstName> <Address> <Street>10932 Bigge Rd.</Street> <City>Menlo Park</City> <State>CA</State> </Address> </Author> ...

Using substring-after to search text in XPath query

I trying to parse a string in an XML node by using an XPath query which requires that I strip out a substring and read the remaining value. The substring may have a dynamic amount of whitespace before and after it before I can get to the value, so it would be helpful to have some sort of a indexOf function to use in the XPath. I'm tryi...