Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I have a task like this, I need to create a winform with flow like this:
a textbox for user input a string value. Then, I choose an available file html, and I want to specify <H1> tag and insert these string to it, for example.
I found something on the internet like HtmlTextWriter class but it does not seem feasible...
Maybe I have not understood yet about HtmlTextWriter.
Could you tell me how to use this...Special Thanks for your help.
Use XElement to rebuild the HTML document
string html = #"<html>
<body><div></div></body>
</html>";
string userIput = "hello world";
var document = XElement.Parse(html);
var newDoc = new XElement(document.Name,
new XElement("body",
new XElement("div",
new XElement("h1") { Value = userIput })));
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 months ago.
Improve this question
Im trying to edit a postcode data which comes as for example 1234567 and i want to put a dash between 123 and 4567 (e.g 123-4567) is it possible to do this within C# without editing the csv file itself?
Im using a generic for loop to read through the csv file but i want to edit it like i asked above.
foreach(string line in csvData_){
string[] col = line.Split(',');
deliveryAddress.Text = col[0];
deliveryPostcode.Text = col[1];
deliveryPostcode contains 1234567 for e.g.
To solve your problem, you can use the method Insert() of the string object.
For example:
deliveryPostcode.Text = col[1].Length == 7 ? col[1].Insert(3, "-") : col[1];
You have to fit it for your needs, but this is the way I would use.
Here is the MSDN page of the String.Insert().
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
In my project; I have so many json file from web. And inside json file have campaign datas. But that data numbers is always changing. For example in first json it have 5 data and other json have 15. So I need create labels for that datas. For example if in the json file have 5 campaign data , i need create 5. İf it have 10 then i need create 10. Like this. So how can i make it ? I input json files and its works correctly i just need learn how can i create , position N label in xamarin ? Thanks for your help! <3
just create them and add them to some layout container, like this
var stack = new StackLayout();
foreach(var l in LabelData())
{
stack.Children.Add(new Label { Text = l.SomeProperty });
}
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
My question is about the following html: https://pastebin.com/qT97gBh5
I download the HTML Site by using
var url = "https://www.twitch.tv/monstercat";
var web = new HtmlWeb();
var doc = web.Load(url);
Now the only thing that interests me is the JSON Data off the following section.
<script type="application/ld+json">[{"#context":"http://schema.org","#type":"VideoObject","thumbnailUrl":["https://static-cdn.jtvnw.net/previews-ttv/live_user_monstercat-{width}x{height}.jpg"],"embedUrl":"https://player.twitch.tv/?channel=monstercat&player=facebook&autoplay=true","name":"Monstercat - Twitch","description":"Non Stop Music - Monstercat Radio 🎶","videoQuality":"1080p","publication":{"#type":"BroadcastEvent","isLiveBroadcast":true,"startDate":"03/29/2020 19:04:06"},"author":{"#type":"Person","name":"Monstercat","url":"https://www.twitch.tv/monstercat"},"uploadDate":"03/29/2020 19:04:06"}]</script>
How would i use HtmlAgilityPack to use the xpath
/html/head/script[2] to receive the JSON Data?
you can search about agility pack in c# and after that use agility to get this X path
/html/head/script[2]
now you have a json string. convert json to property with newtonsoft(add this package with Nuget).congratulation so you can read description in your class.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I want to download a specif string from website but I am not sure how I achieve it the best way.
Right now I do it like this:
using (WebClient webClient = new WebClient())
{
string htmlString = webClient.DownloadString(url);
string encoding = WebUtility.UrlDecode(htmlString);
Console.WriteLine(encoding);
}
However, this returns the whole webpage as a string, can I somehow only download a specific part of the URL?
If the webserver support byte serving (Accept-Ranges header) then you can access a part of the document.
https://en.wikipedia.org/wiki/Byte_serving
https://msdn.microsoft.com/library/7fy67z6d(v=vs.100).aspx
https://blogs.msdn.microsoft.com/webdev/2012/11/23/asp-net-web-api-and-http-byte-range-support/
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I want to scan a portion of the webpage for specific URLs using htmlagilitypack and C#. How can I do it? For example I would like to scan only the links of the ads from this page http://www.olx.in/mobile-phones-cat-831 and not all the links.
It looks like each of the Add links is nested inside a div with a specific class (adListDetails), so one can look for any links inside a div with said class. That would look like this:
var nodes = document.DocumentNode.SelectNodes("//div[class='#adListDetails']//a[#src]");
foreach (var node in nodes)
{
string src = node.Attributes["src"].Value;
}
Learn more XPath from a source like w3schools.