|
|
SoftXML Homepage | Download SoftXpath | Send your feedback for SoftXpath |
SoftXPath is small cross browser JavaScript library written for web developers who deals with XML parsing/querying on client side. With the help of SoftXPath you will be able to query complex XML documents using powerful Xpath expressions. Now you can focus on building effective Xpath expressions instead of wasting time on browser compatibility issues.
Browsers supported:
Move mouse over icon to see version support
SoftXPath has 4 methods for XML manipulation:
Include SoftXPath library in your file
<script language="javascript" src="SoftXPath.js"></script>
Create new instance of SoftXpath
var myXpathObj = new SoftXpath();
Method | Description | Example | Result |
---|---|---|---|
load | expects valid path to xml file as parameter and loads given file |
myXpathObj.load("flash_vs_page.xml") | true/false |
loadXML | expects valid xml string as parameter and loads given string | myXpathObj.loadXML("<root><item id='2'>demo1</item></root>") | true/false |
selectNodes | expects valid xpath expression and returns array of objects | results = myXpathObj.selectNodes("//item[@id='2']") | results = myXpathObj.selectNodes("//item[@id='2']"); Check array length to see if there are matched nodes: if(results.length==0){ alert("No records found"); } else { //loop over matched nodes |
registerNamespace | expects prefix/URI pair and sets user defined namespaces default is none - myXpathObj.registerNamespace("","") |
myXpathObj.registerNamespace("xsl","http://www.softxml.com") |
SoftXPath.registerNamespace("xsl","http://www.softxml.com") |
Our XML file called "flash_vs_page.xml" and it's structure shown below:
<?xml version="1.0"?> <xsl:categories xmlns:xsl="http://www.softxml.com"> <xsl:category name="CLeasing"> <xsl:language name="en"> <xsl:page name="aboutSixt.asp" value="video_41.swf"/> <xsl:page name="aboutUs.asp" value="video_42.swf"/> <xsl:page name="advantage.asp" value="video_43.swf"/> <xsl:page name="club.asp" value="video_44.swf"/> <xsl:page name="Cservice.asp" value="video_45.swf"/> <xsl:page name="infoSafety.asp" value="video_46.swf"/> <xsl:page name="LetterFinal.asp" value="video_47.swf"/> <xsl:page name="orderInfo.asp" value="video_48.swf"/> <xsl:page name="pressRelease.asp" value="video_49.swf"/> <xsl:page name="Resultview.asp" value="video_50.swf"/> <xsl:page name="roadTests.asp" value="video_51.swf"/> <xsl:page name="SearchAdvanceB.asp" value="video_52.swf"/> <xsl:page name="SearchQuickB.asp" value="video_53.swf"/> <xsl:page name="SearchResultB.asp" value="video_54.swf"/> <xsl:page name="service.asp" value="video_55.swf"/> <xsl:page name="SI_jobs.asp" value="video_56.swf"/> <xsl:page name="SI_orderFix.asp" value="video_57.swf"/> <xsl:page name="SI_writeus.asp" value="video_58.swf"/> <xsl:page name="SupplementsB.asp" value="video_59.swf"/> <xsl:page name="ResultView.asp" value="video_60.swf"/> <xsl:page name="branches.asp" value="video_61.swf"/> <xsl:page name="login.asp" value="video_62.swf"/> <xsl:page name="makelogin.asp" value="video_63.swf"/> <xsl:page name="personal.asp" value="video_64.swf"/> </xsl:language> <xsl:language name="he"> <xsl:page name="aboutSixt.asp" value="new_kopel_key_120x150.swf"/> <xsl:page name="aboutUs.asp" value="new_kopel_key_120x151.swf"/> <xsl:page name="advantage.asp" value="new_kopel_key_120x152.swf"/> <xsl:page name="club.asp" value="new_kopel_key_120x153.swf"/> <xsl:page name="Cservice.asp" value="new_kopel_key_120x154.swf"/> <xsl:page name="infoSafety.asp" value="new_kopel_key_120x155.swf"/> <xsl:page name="LetterFinal.asp" value="new_kopel_key_120x156.swf"/> <xsl:page name="orderInfo.asp" value="new_kopel_key_120x157.swf"/> <xsl:page name="pressRelease.asp" value="new_kopel_key_120x158.swf"/> <xsl:page name="accident.asp" value="new_kopel_key_120x159.swf"/> <xsl:page name="Resultview.asp" value="new_kopel_key_120x160.swf"/> <xsl:page name="roadTests.asp" value="new_kopel_key_120x161.swf"/> <xsl:page name="SearchAdvanceB.asp" value="new_kopel_key_120x162.swf"/> <xsl:page name="SearchQuickB.asp" value="new_kopel_key_120x163.swf"/> <xsl:page name="SearchQuickBNew.asp" value="new_kopel_key_120x164.swf"/> <xsl:page name="icar.asp" value="new_kopel_key_120x165.swf"/> <xsl:page name="SearchResultB.asp" value="new_kopel_key_120x166.swf"/> <xsl:page name="service.asp" value="new_kopel_key_120x167.swf"/> <xsl:page name="SI_jobs.asp" value="new_kopel_key_120x168.swf"/> <xsl:page name="SI_orderFix.asp" value="new_kopel_key_120x169.swf"/> <xsl:page name="SI_writeus.asp" value="new_kopel_key_120x170.swf"/> <xsl:page name="SupplementsB.asp" value="new_kopel_key_120x171.swf"/> <xsl:page name="branches.asp" value="new_kopel_key_120x172.swf"/> <xsl:page name="login.asp" value="new_kopel_key_120x173.swf"/> <xsl:page name="makelogin.asp" value="new_kopel_key_120x174.swf"/> <xsl:page name="personal.asp" value="new_kopel_key_120x175.swf"/> </xsl:language> </xsl:category> </xsl:categories> |
Example - edit javascript code below and then click "Try it yourself" button |
Our XML string shown below - you can edit XML below:
Example - edit javascript code below and then click "Try it yourself" button
|