|
Hi,
You can use XPath for this.
Below is a code snippet:
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(@"C:\SystemX.xml");
string xPath = "/Systems/systemData[name='Name5']";
XmlNode xmlNode = xmlDoc.SelectSingleNode(xPath);
if (xmlNode == null)
{
MessageBox.Show("Name5 not found");
}
Hope this helps.
Good luck!
Integrity is telling myself the truth. And honesty is telling truth to other people.
My Blog![ ^]
|
|
|
|
|
XmlNode NodeItems = XMLdoc.SelectSingleNode("Systems/Systemdata/name");
NodeItem.InnerText will give you VALUE in particular node
|
|
|
|
|
Hello everyone,
I have an xml file name is questions.xml, I am checking these questions by using .xsd file but I need to load them in to jquery flipcard in order to show them on the html file, I will paste my questions.xml file here so could you please help me how to load these questions one by one using jquery flipcard and xml file?
questions.xml
Statement of Intent
Cut-off Claim
Indian Reserve
Treaty Right
Esquimalt & Nanaimo Railway
Fiduciary Duty
Douglas Treaties
Indian Act
Indian Reserve
Esquimalt & Nanaimo Railway
Band
Section 35
First Nation
Band Council
Statement of Intent
Cut-off Claim
Esquimalt & Nanaimo Railway
Fiduciary Duty
Statement of Intent
Cut-off Claim
Indian Reserve
Section 35
Indian Act
First Nation
Indian Reserve
Douglas Treaties
Band
Indian Act
Indian Reserve
Band
Fiduciary Duty
First Nation
First Nation
Statement of Intent
Band Council
Indian Reserve
Treaty Right
Statement of Intent
Treaty
Section 35
Cut-off Claim
Treaty Right
First Nation
Indian Reserve
Indian Act
Treaty
Band Council
Treaty Right
Section 35
Band
First Nation
Statement of Intent
Statement of Intent
Readiness
Interim Measures
INAC (Indian & Northern Affairs)
Interim Measures
First Nation
Main Table
Ministry of Aboriginal Affairs (MAA)
INAC (Indian & Northern Affairs)
Unity Protocol
Ministry of Aboriginal Affairs (MAA)
Readiness
Unity Protocol
British Columbia Treaty Commission (BCTC)
Hul'qumi'num Treaty Group
First Nations Summit
Hul'qumi'num Treaty Group
INAC (Indian & Northern Affairs)
British Columbia Treaty Commission (BCTC)
Third Parties
Unity Protocol
Main Table
Interim Measures
Hul'qumi'num Treaty Group
INAC (Indian & Northern Affairs)
Hul'qumi'num Treaty Group
Ministry of Aboriginal Affairs (MAA)
Unity Protocol
Hul'qumi'num Treaty Group
Third Parties
Ministry of Aboriginal Affairs (MAA)
Interim Measures
Main Table
British Columbia Treaty Commission (BCTC)
Unity Protocol
Hul'qumi'num Treaty Group
Ministry of Aboriginal Affairs (MAA)
Interim Measures
Third Parties
First Nations Summit
Framework Agreement
Land-based Jurisdictional Model
Land Tenure
RFiscal Arrangements
Aboriginal Rights
Expropriation
Treaty Mandates
Extinguishment
Aboriginal Title
Land-based Jurisdictional Model
Crown Grant
Expropriation
Aboriginal Rights
Land Tenure
Fiscal Arrangements
Treaty Mandates
Extinguishment
Aboriginal Rights
Framework Agreement
Expropriation
Land Tenure
Aboriginal Title
Extinguishment
Aboriginal Rights
Treaty Mandates
Land-based Jurisdictional Model
Expropriation
Extinguishment
Aboriginal Rights
Crown Grant
Treaty Mandates
Aboriginal Title
Land Tenure
Extinguishment
Aboriginal Title
Crown Grant
Aboriginal Title
Framework Agreement
Expropriation
Fiscal Arrangements
Overlaps
Crown Activity
Agreement in Principle (AIP)
Traditional Territory
Food Fish
Traditional Territory
Crown Tenure
Underlying Title
Food Fish
Crown Activity
Crown Tenure
Underlying Title
Traditional Territory
Crown Land
Food Fish
Land Quantum
Agreement in Principle (AIP)
Crown Tenure
Sub-surface
Underlying Title
Crown Activity
Traditional Territory
Crown Land
Sub-Surface
Sub-surface
Agreement in Principle (AIP)
Food Fish
Crown Activity
Food Fish
Traditional Territory
Crown Activity
Underlying Title
Crown Land
Land Quantum
Crown Tenure
Crown Activity
Overlaps
Crown Land
Sub-surface
Land Quantum
Final Agreement
Constitution
Expropriation
Indemnity
Expropriation
Citizenship Code
Eligibity
Compensation
Citizenship Code
Constitution
Compensation
Final Agreement
Eligibity
Self-Government
Citizenship Code
Indemnity
Compensation
Eligibity
Constitution
Final Agreement
Constitution
Final Agreement
Eligibity
Expropriation
Compensation
Final Agreement
Constitution
Citizenship Code
Citizenship Code
Constitution
Eligibity
Indemnity
Jurisdiction
Legal Uniformity
Implementation
Ratification
Resource-revenue Sharing
Ratification
Cooperative Management
Specific Claim
Financial Transfer Arrangements
Treaty Settlement Land
First Nations Roads
Legal Uniformity
Jurisdiction
Resource-revenue Sharing
Cooperative Management
Treaty Settlement Land
First Nations Roads
Resource-revenue Sharing
Capacity-building
Implementation
Treaty Settlement Land
Legal Uniformity
Resource-revenue Sharing
Cooperative Management
Treaty Settlement Land
Jurisdiction
Cooperative Management
Legal Uniformity
Ratification
Resource-revenue Sharing
Specific Claim
Financial Transfer Arrangements
Implementation
First Nations Roads
Financial Transfer Arrangements
Capacity-building
Treaty Settlement Land
Financial Transfer Arrangements
First Nations Roads
Cooperative Management
Resource-revenue Sharing
Financial Transfer Arrangements
Specific Claim
Jurisdiction
|
|
|
|
|
Hi Guys,
I am doing xslt transformation on a sample xmldoc using the xslt below. The problem I am having is its not matching on the 'Publication' tag. If I remove the namespace it works fine. Is there a way to get the match on the 'Publication' tag with the namespace in it?
Any help would be much appreciated,
Thanks.
----Sample XML------
="1.0"="utf-8"
<Publication xmlns="http://www.mycompany.com/Sampleproject/XmlSchema">
<PublicationDetails>
<AgencyId>1</AgencyId>
<PublicationId>PublicationId1</PublicationId>
<PublicationDateTime>1900-01-01T01:01:01-07:00</PublicationDateTime>
<OriginatingSystemName>OriginatingSystemName1</OriginatingSystemName>
<DestinationSystemName>DestinationSystemName1</DestinationSystemName>
</Publication>
---- Sample Xslt ------
="1.0"="utf-8"
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
<xsl: output method="xml" indent="yes"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="Publication">
<xsl:apply-templates select ="PublicationDetails"/>
</xsl:template>
<xsl:template match="PublicationDetails">
<SubmittingAgency>
</SubmittingAgency>
</xsl:template>
</xsl:stylesheet>
|
|
|
|
|
I would like to convert the text data to uppercase and I wrote the expression as below
"/RawData/page/text[upper-case(.)='ABC']" its throwing an exception "XsltContext is needed for this query because of an unknown function"
Reference:
http://www.w3schools.com/xpath/xpath_functions.asp
a
|
|
|
|
|
problem solved with translate function.
textNode = docRawData.SelectSingleNode("/RawData/page/text[translate(text(),\"abcdefghijklmnopqrstuvwxyz\",\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\")='" + rows[n].Trim() + "']");
|
|
|
|
|
Hi,
I'm trying to get the text element which contains value 1.345%, I tried as below to get the results. but the nodeList count is 0. please correct to get the correct results
XmlNodeList nodeList = rawData.SelectNodes("/RawData/page/text[.=<![CDATA[1.345%]]>");
If the value is simple text or integer, its working fine with the below code.
XmlNodeList nodeList = rawData.SelectNodes("/RawData/page/text[.='corporation'");
|
|
|
|
|
Both examples are missing a right square backet. If your second example works though then that wouldn't be the cause. But you should still fix it.
Instead the problem is that you can't treat CDATA like that. At least googling suggests you can't.
|
|
|
|
|
I just forgot to put right square bracket. what to do, to make it work with the value "10.5%" instead "corporation". Thanks in advance
XmlNodeList nodeList = rawData.SelectNodes("/RawData/page/text[.='corporation']");
|
|
|
|
|
I found that the problem is not with "%". The values is having extra spaces as " 10.34%"
So the below expression is not working.
"/Data/page/content[.='10.34%']".
its working with the expression "/Data/page/content[.=' 10.34%']".
Please guide me to solve this issue. Thanks in advance
<Data>
<page>
<content> 10.34%</content>
</page>
</Data>
|
|
|
|
|
Issued solved with the below expression
"/Data/page/content[normalize-space(.)='10.34%']".
|
|
|
|
|
Hello
I have question how can I put condition in my programming in windows phone application?
for example, if I want but code for help user when use my application the users cannot add number more than 80 in text box how I do it ?
Could you please help me !!!!
Kind regards
|
|
|
|
|
Sounds like you are trying to add range validation to a textbox, but I doubt you are working with XML/XSL. See the forum list to find the forum appropriate for your question. Or you can ask a question in the general "Quick Answers" forum.
Martin Fowler wrote: Any fool can write code that a computer can understand. Good programmers write code that humans can understand.
|
|
|
|
|
You could have posted this in a C# forum, you can get an answer much quciker than here. Make sure you are in the right place before posting a question.
Try this:
try
{
Int32 number = Int32.Parse(txtBoxId.Text);
if(number <= 80)
{
}
else
{
}
}
catch(Excemption e)
{
throw new Excemption("Not a valid interger!");
}
That's a basic function you need, you can call this function on your desired textbox events e.g. on onkeypress.
Hope this helps,
Morgs
|
|
|
|
|
|
Hi, I am having a problem in displaying XML in HTML as shown below -
XML:-
<ABC>
<DEF>
<GHI>Heading</GHI>
<P/> Hello, How are you?
<P/> I am a Developer.
</DEF>
</ABC>
XSLT:-
?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>xml to html</h2>
<table border="0">
<xsl:for-each select="ABC/DEF">
<tr>
<td><xsl:value-of select="GHI" /></td><br/>
<td><xsl:value-of select="." /></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
OUTPUT -
Heading
HeadingHello, How are you?I am a Developer.
I want Heading to be in line 1 and then a line break and then comes paragraph. Also i want a space/line break between two paragraphs.
How to get following output instead -
Heading
Hello, How are you?
I am a Developer.
Thanks
Andyyy
|
|
|
|
|
Your HTML is faulty.
<table>
<xsl:for-each select="ABC/DEF">
<tr><td><xsl:value-of select="GHI"/></td></tr>
<xsl:for-each select="p">
<tr><td>
<xsl:value-of select="."/>
</td></tr>
</xsl:for-each>
</xsl:for-each>
</table>
You're using columns (TD) instead of rows (tr).
Also, change your XML to:
<GHI>Heading</GHI>
<p>Hello, How are you?</p>
<p>I am a Developer.</p>
|
|
|
|
|
Thanks for your reply.
I agree with you about HTML part.
But this part of your suggested code doesn't work as it doesn't display paragraphs -
<xsl:for-each select="p">
<tr><td>
<xsl:value-of select="."/>
</td></tr>
</xsl:for-each>
The problem is, i have received XML from third party and there are hundreds of XML that needs to be displayed on webpage and everywhere they have used
<p/>
Paragraph 1
<p/>
Paragraph 2
So should i ask the client to produce XML correctly or is there any work around to be able to display each paragraph in separate line.
Thanks
|
|
|
|
|
You need to identify the inline paragraph and break up the output based on this. I'm platying with the idea but am getting stuck around mixing up carriage returns and line feeds, grrr!
Rhys
"Technological progress is like an axe in the hands of a pathological criminal"
"Two things are infinite: the universe and human stupidity; and I'm not sure about the the universe"
|
|
|
|
|
If you can get them to parse it correctly, great. Otherwise, try yours again with the right HTML code to see if it can work. I wasn't able to get it myself.
|
|
|
|
|
Have you tried something like this:
<xsl:template match="*|text()">
<xsl:value-of select="."/>
</xsl:template>
And then where you have this:
<xsl:for-each select="ABC/DEF">
<tr>
<td><xsl:value-of select="GHI" /></td><br/>
<td><xsl:value-of select="." /></td>
</tr>
replace the second
<td> line:
<td><xsl:apply-templates/></td>
Edit: sorry, fixed the formatting
|
|
|
|
|
Thanks,
Just tried it but doesn't work -
Here is the html/javascript I am using to call xml and xsl - just incase there is some problem in script instead:-
<html>
<head>
<script type="text/javascript">
function loadXMLDoc(dname)
{
if (window.XMLHttpRequest)
{
xhttp=new XMLHttpRequest();
}
else
{
xhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xhttp.open("GET",dname,false);
xhttp.send("");
return xhttp.responseXML;
}
function displayResult()
{
xml=loadXMLDoc("test.xml");
xsl=loadXMLDoc("test.xsl");
if (window.ActiveXObject)
{
ex=xml.transformNode(xsl);
document.getElementById("example").innerHTML=ex;
}
else if (document.implementation && document.implementation.createDocument)
{
xsltProcessor=new XSLTProcessor();
xsltProcessor.importStylesheet(xsl);
resultDocument = xsltProcessor.transformToFragment(xml,document);
document.getElementById("example").appendChild(resultDocument);
}
}
</script>
</head>
<body onLoad="displayResult()">
<div id="example" />
</body>
</html>
Thanks
|
|
|
|
|
The below is not perfect but is getting there. Unfortunately I need to leave the office soon but hope it helps...
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head>
<title>Updated Template</title>
</head>
<body>
<table border="0">
<xsl:for-each select="ABC/DEF">
<tr>
<td><xsl:value-of select="GHI" /></td>
</tr>
<tr>
<td>
<xsl:variable name="inStr" select="."></xsl:variable>
<xsl:variable name="outStr">
<xsl:call-template name="template2">
<xsl:with-param name="parameter2" select="$inStr"/>
</xsl:call-template>
</xsl:variable>
<xsl:copy-of select="$outStr"/>
</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
<xsl:template name="template2">
<xsl:param name="parameter2"/>
<xsl:choose>
<xsl:when test="contains($parameter2,'')">
<xsl:value-of select="substring-before($parameter2,'')"/><p/>
<xsl:call-template name="template2">
<xsl:with-param name="parameter2">
<xsl:value-of select="substring-after($parameter2,'')"/>
</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$parameter2"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
Rhys
"Technological progress is like an axe in the hands of a pathological criminal"
"Two things are infinite: the universe and human stupidity; and I'm not sure about the the universe"
|
|
|
|
|
Thanks goblinTech,
It's getting there - output am getting is
Heading
Heading
Hello,
How
are
you?
I
am
a
Developer.
I will keep trying.
Thanks for your help.
|
|
|
|
|
You would find this so much easier if your xml was actually xml rather than just having a .xml extension and being a mixture of xml, html and plain text.
I would just tell the client to supply proper input if they want proper output. But then I tend to work for captive clients which makes life a lot easier.
Every man can tell how many goats or sheep he possesses, but not how many friends.
|
|
|
|