Skip to content

Commit e817dc0

Browse files
committed
Merge Css and Html packages into one Web
These two will most likely be used in conjunction most of the time, so why not just make it a single package!
1 parent 7ab0f96 commit e817dc0

14 files changed

Lines changed: 41 additions & 99 deletions

.netconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,3 +162,8 @@
162162
sha = 9a1b07589b9bde93bc12528e9325712a32dec418
163163
etag = b54216ac431a83ce5477828d391f02046527e7f6fffd21da1d03324d352c3efb
164164
weak
165+
[file "src/Web/System/Xml/XmlWrappingReader.cs"]
166+
url = https://github.com/devlooped/catbag/blob/main/System/Xml/XmlWrappingReader.cs
167+
sha = b1f3e12a7107dc81de53fd0a962bd4a149ab1ef7
168+
etag = b2c97f61df993f05a7d6e3627ab10e7933528ad33d91be4ac16323756c522b6b
169+
weak

Html.sln

Lines changed: 0 additions & 38 deletions
This file was deleted.

Css.sln renamed to Web.sln

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ VisualStudioVersion = 17.0.31612.314
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tests", "src\Tests\Tests.csproj", "{2E8FE01D-35EB-49E2-B693-490F4ABFDD5D}"
77
EndProject
8-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Css", "src\Css\Css.csproj", "{442D46AA-C4DC-4AEE-826B-CE98A9C6F837}"
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Web", "src\Web\Web.csproj", "{442D46AA-C4DC-4AEE-826B-CE98A9C6F837}"
99
EndProject
1010
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F2D75BE9-587E-46CC-BFE4-D5BA538E325A}"
1111
ProjectSection(SolutionItems) = preProject
1212
.editorconfig = .editorconfig
13-
global.json = global.json
13+
.netconfig = .netconfig
1414
readme.md = readme.md
1515
EndProjectSection
1616
EndProject

readme.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
![Icon](https://raw.githubusercontent.com/devlooped/css/main/assets/img/icon-32.png) XLinq to Css
1+
![Icon](https://raw.githubusercontent.com/devlooped/css/main/assets/img/icon-32.png) HTML => XML + CSS with XLinq 🤘
22
============
33

44
[![Version](https://img.shields.io/nuget/vpre/Devlooped.Xml.Css.svg?color=royalblue)](https://www.nuget.org/packages/Devlooped.Xml.Css)
55
[![Downloads](https://img.shields.io/nuget/dt/Devlooped.Xml.Css.svg?color=green)](https://www.nuget.org/packages/Devlooped.Xml.Css)
66
[![License](https://img.shields.io/github/license/devlooped/css.svg?color=blue)](https://github.com/devlooped/css/blob/main/license.txt)
77

8-
Implements CSS selectors for XLinq.
8+
Read HTML as XML and query it with CSS over XLinq.
9+
10+
No need to learn an entirely new object model for a page 🤘.
11+
This makes it the most productive and lean library for web
12+
scraping using the latest and greatest that .NET can offer.
913

1014
# Usage
1115

@@ -16,9 +20,20 @@ using Devlooped.Web;
1620
XDocument page = HtmlDocument.Load("page.html")
1721
IEnumerable<XElement> elements = page.CssSelectElements("div.menuitem");
1822

19-
XElement title = page.CssSelectElement("div[role=alert]");
23+
XElement title = page.CssSelectElement("html head meta[name=title]");
2024
```
2125

26+
By default, `HtmlDocument.Load` will skip non-content elements `script` and
27+
`style`, turn all element names into lower case, and ignore all XML namespaces
28+
(useful when loading XHTML, for example) for easier querying. These options
29+
as well as granular whitespace handling can be configured using the overloads
30+
receiving an `HtmlReaderSettings`.
31+
32+
The underlying parsing is performed by the amazing [SgmlReader](https://www.nuget.org/packages/Microsoft.Xml.SgmlReader)
33+
library by Microsoft's [Chris Lovett](http://lovettsoftware.com/).
34+
35+
## CSS
36+
2237
At the moment, supports the following CSS selector features:
2338

2439
- [Type selector](https://www.w3.org/TR/selectors-3/#type-selectors)

src/Html/Html.csproj

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/Tests/HtmlTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System.Xml;
22
using System.Xml.Linq;
33
using System.Xml.XPath;
4-
using Devlooped.Html;
4+
using Devlooped.Web;
55

66
namespace Devlooped.Tests;
77

src/Tests/Tests.csproj

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<PropertyGroup>
44
<TargetFramework>net6.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
6+
<AssemblyName>Devlooped.Tests</AssemblyName>
67
</PropertyGroup>
78

89
<ItemGroup>
@@ -15,13 +16,11 @@
1516
<ItemGroup>
1617
<Using Include="Xunit" />
1718
<Using Include="Xunit.Abstractions" />
18-
<Using Include="Devlooped.Xml.Css" />
19-
<Using Include="Devlooped.Html" />
19+
<Using Include="Devlooped.Web" />
2020
</ItemGroup>
2121

2222
<ItemGroup>
23-
<ProjectReference Include="..\Css\Css.csproj" />
24-
<ProjectReference Include="..\Html\Html.csproj" />
23+
<ProjectReference Include="..\Web\Web.csproj" />
2524
</ItemGroup>
2625

2726
<ItemGroup>

src/Css/Css.cs renamed to src/Web/Css.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using System.Linq;
66
using System.Text;
77

8-
namespace Devlooped.Xml.Css;
8+
namespace Devlooped.Web;
99

1010
class SelectorGroup : List<Selector>
1111
{
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
using System.Xml.XPath;
77
using System.Xml.Xsl;
88

9-
namespace Devlooped.Xml.Css;
9+
namespace Devlooped.Web;
1010

1111
/// <summary>
1212
/// Provides extension methods for <see cref="XNode"/> that allow selecting
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using System.Xml.Linq;
66
using Sgml;
77

8-
namespace Devlooped.Html;
8+
namespace Devlooped.Web;
99

1010
/// <summary>
1111
/// Allows loading an HTML document as an <see cref="XDocument"/>.

0 commit comments

Comments
 (0)