|
Are you sure?
The best things in life are not things.
|
|
|
|
|
In a year, one should be able to. This guy? Well, come to your own conclusion
|
|
|
|
|
Hi,
I would like to get "Token" value based on the description from the below xml file.
For example, if my input is 'Company'(Description), it should return 'COS'(Token).
I tried with XPath. But not working due to multi level of nodes in xml. Could you pls guide me to achieve this. Thanks in advance.
<CodeList>
<Entity>
<Token>PROD</Token>
<Description>prod</Description>
<Entity>
<Token>BUSINESS</Token>
<Description>Business News</Description>
<Entity>
<Token>COS</Token>
<Description>Company News</Description>
<Entity>
<Token>ANA</Token>
<Description>Analyst Ratings</Description>
<Entity>
<Token>ANAMOVES</Token>
<Description>Analyst Ratings, Estimates and Target Price Changes</Description>
<Entity>
<Token>ANACHANGE</Token>
<Description>Analyst Rating Changes</Description>
<Entity>
<Token>ANACUT</Token>
<Description>Analyst Downgrades</Description>
<Entity>
<Token>ANACUTEVT</Token>
<Description>Analyst Ratings Cut Events, Announcements</Description>
</Entity>
</Entity>
</Entity>
</Entity>
<Entity>
<Token>IP</Token>
<Description>Intellectual Property</Description>
<Entity>
<Token>COPYRIGHT</Token>
<Description>Copyrights</Description>
</Entity>
</Entity>
</Entity>
</Entity>
<Entity>
<Token>DRGPATENT</Token>
<Description>Drug Patents</Description>
</Entity>
</Entity>
</Entity>
</CodeList>
|
|
|
|
|
Use // to search in any level into your XML.
The following XPath will give you what you want:
//Entity[contains(./Description, 'Company')]/Token
|
|
|
|
|
Thank you Mirko1980, its working
|
|
|
|
|
You could use Linq to XML[^]
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Good afternoon.
We created a control (somecontrol.cs) which displays a dynamic bullet list. In some scenerios, one of the bullets will have a hyperlink.
The problem is, the a href code renders as text. We are adding to a string List and using it as the DataSource for the bulleted list:
private BulletedList _blConfirmText = new BulletedList();
List<string> displayText = new List<string>();
_confirmText.Text = CONFIRMTEXTLB;
displayText.Add(BULLETONELB);
displayText.Add(BULLETTWOLB);
if (hasUpdateAccess)
displayText.Add(BULLETTHREELBHL);
else
displayText.Add(BULLETTHREELB);
_blConfirmText.CssClass = "bulletItems";
_blConfirmText.DataSource = displayText;
_blConfirmText.DataBind();
Any idea how to get this to render correctly? Any suggestions? Thank you, WHEELS
|
|
|
|
|
What type of control is it? Is it a WinForm User control?
There's no magic wand that will parse your href string and display it as a link automatically, you'll have to write your own logic to achieve this behavior.
EDIT: I see that you're trying to create some sort of a Web User Control. Can you show some code where the actual rendering happens?
|
|
|
|
|
private const string BULLETTHREELBHL = "This is an example of the hyperlink <a href=\"/../Test/FW_DEFAULT.ASPX?Serviceid=Test&title=Test+Page>Test Page\"</a> where people click to navigate to another page.";
|
|
|
|
|
Your HTML is invalid (the quotes around the attribute value aren't done right).
|
|
|
|
|
Hi Bob. What should they be? WHEELS
|
|
|
|
|
private const string BULLETTHREELBHL = "This is an example of the hyperlink <a href=\"/../Test/FW_DEFAULT.ASPX?Serviceid=Test&title=Test+Page\">Test Page</a> where people click to navigate to another page.";
EDIT: If it still doesn't work, make sure that it is not Html encoded before being rendered. For example. The Text property of some controls automatically Html encode their content. So if you put html tags inside the Text property, they'll be renedered as html tags.
|
|
|
|
|
private const string BULLETTHREELBHL = "This is an example of the hyperlink <a href=\"/../Test/FW_DEFAULT.ASPX?Serviceid=Test&title=Test+Page\">Test Page</a> where people click to navigate to another page.";
If you can't fix mistakes like that in HTML then why are you writing websites ...
|
|
|
|
|
Thanks Bob and Shameel. We had done some modifications to this code and when we put it back, we must have put the syntax back incorrectly. Unfortunately after fixing the code, it still renders as text.
WHEELS
|
|
|
|
|
You still haven't shown the code that actually renders this text. Do other HTML tags work correctly? If your user control simply renders the text literally into the HTML stream then it should work so I'm guessing something is wrong in that area.
|
|
|
|
|
It is being Html encoded before being rendered. As I said in my previous post, certain controls automatically html encode their content before rendering. Just to test if that is the actual problem, try using a div tag (HtmlGenericControl) and set its innerText property to the desired html output.
|
|
|
|
|
Hi Shameel. The text renders correctly when set up as a label directly on the page. I believe you are correct about the encoding issue. Is there a way to decode? WHEELS
|
|
|
|
|
It depends on how you render the output. You have still not shown the code that actually renders your html output.
|
|
|
|
|
I had to abandon the Common control approach. I added a simple BulletedList to the .aspx file, but I am still having a very challenging time setting a hyperlink on a given word in a bullet sentence. I am starting to believe this can't be done.
There are three DisplayMode options for a BulletedList: Text, HyperLink, and ImageButton, but no Text/Hyperlink combo.
If you have time can you try to create one that does what I am looking for?
Thanks, WHEELS
|
|
|
|
|
Bulleted list and hyperlink will definitely work. Try this:
<ul>
<li><a href="http://google.com">Google</a></li>
<li><a href="http://bing.com">Bing</a></li>
</ul>
|
|
|
|
|
Sorry Shameel. I was not entirely clear. I have done that sucessfully, but what I am looking for is the following:
* This is an example of <hyperlink on="" the="" word="" good=""> programming. Then when you click the underlined word good it takes you to http://www.codeproject.com.
* is a bullet.
WHEELS
|
|
|
|
|
I dont see any problem with that too:
<ul>
<li>To Access Google, click <a href="http://google.com">here</a></li>
<li><a href="http://bing.com">This</a> takes you to Bing</li>
</ul>
|
|
|
|
|
It seems to work well in the .aspx, but now I have to put it in as a dynamic variable. Is there any issue with including the a href in the string?
WHEELS
|
|
|
|
|
Depends on how you put the 'href' within that string. As long as the correct html is rendered, you shouldn't have any problem. Can you care to show me your entire code that renders the output?
|
|
|
|
|
<ul>
<li id="liBullet" />
<li><a href="http://bing.com">This</a> takes you to Bing</li>
</ul>
C#
protected System.Web.UI.WebControls.ListItem liBullet;
this.liBullet.Attributes.Add(BULLETTHREELBHL);
private const string BULLETTHREELBHL = "Employee earnings can be submitted through the <a href=\"/EECHG/FW_DEFAULT.ASPX?Serviceid=EECHG&title=Employee+Changes\">Employee Changes</a> service by a plan administrator with access to update employee changes.";
WHEELS
|
|
|
|