| | |
Basic xpath question..
Please support our XML, XSLT and XPATH advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Aug 2009
Posts: 2
Reputation:
Solved Threads: 0
I'm new to xpath.. probably very simple, but I haven't been able to figure it out. I'm working with the following xml structure:
Now, I accessed this item from a list of items with xpath using the unique id and the nodeValue for <name> and <accessoryGroup>:
The above code works fine, but when I try to get the attribute "price" from the child <pricing...>, I have a problem. I know it's probably something very simple, given the simplicity of xpath... but I'm retarded and i don't feel like ripping any more hair out. Below is the code that's not working:
Thanks in advance,
Yitzhak
<item dateExpires="0" doNotPublish="0" manufacturer="" productDetailURL="" id="BKIT1009" type="2">
<pricing price="29.99" retailMarkup="0" retailPrice="0" saleMarkDown="0" salePrice="0" saleType="0" stockPrice="29.99" taxableNational="1" taxableRegional="1"/>
</availability>
<accessoryGroup>misc</accessoryGroup>
<name>2 Piece Kit</name>
<briefDescription>2 Piece Kit</briefDescription>
<description>2 Piece Kit</description>
<invoiceDescription>2 Piece Kit</invoiceDescription>
<moreDetailLink></moreDetailLink>
<downloadStorage></downloadStorage>
</item>Now, I accessed this item from a list of items with xpath using the unique id and the nodeValue for <name> and <accessoryGroup>:
$feed = new DomDocument;
$feed->load('telusAccessories.xml');
$xpath = new DOMXPath($feed);
if (count($accessories) > 1)
{
print "<strong>Accessories:</strong><br />";
foreach( $accessories as $ID )
{
$includes = $xpath->query("/accessories/item[@sku='".$ID."']/accessoryGroup");
if (!($includes->item(0)->nodeValue)=="")
print $includes->item(0)->nodeValue.": ";
$includes = $xpath->query("/accessories/item[@sku='".$ID."']/name");
if (!($includes->item(0)->nodeValue)=="")
print $includes->item(0)->nodeValue."<br />";
}
}
else
{
print "No accessories for selected item.";
}The above code works fine, but when I try to get the attribute "price" from the child <pricing...>, I have a problem. I know it's probably something very simple, given the simplicity of xpath... but I'm retarded and i don't feel like ripping any more hair out. Below is the code that's not working:
$includes = $xpath->query("/accessories/item[@sku='".$ID."']/pricing[@price]");
print $includes->item(0)->nodeValue;Thanks in advance,
Yitzhak
•
•
Join Date: Aug 2009
Posts: 2
Reputation:
Solved Threads: 1
please give me the details about Xpath what it is tickets
Cheap Sports Concerts and Theater Tickets from the Leading Discount Ticket Agent Online
![]() |
Similar Threads
- XPath question (Java)
- Getting a math calculation (nubie question) (XML, XSLT and XPATH)
- VBscript in a Visual Basic Application (Visual Basic 4 / 5 / 6)
- Basic SQL question! (MS SQL)
- Basic Access Question (MS Access and FileMaker Pro)
- Basic Variables Question (Visual Basic 4 / 5 / 6)
- Basic scripting question (Getting Started and Choosing a Distro)
Other Threads in the XML, XSLT and XPATH Forum
- Previous Thread: simple xpath question
- Next Thread: Extracting xml with php
| Thread Tools | Search this Thread |
api blogger blogging code delete development dynamiccreationofnvariablesinxslt error firstthreecharacterofastringrequired flipbook gdata google html include java link linspire linux microsoft news node openoffice overwrite precedence programming rss standards swf template transform variable w3c web xml xmlnotloading xmlonserver xsl xslt





