首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Xpath/HtmlAgilityPack插入标记,page...program下四分之一的长度挂起

使用Xpath/HtmlAgilityPack插入标记,page...program下四分之一的长度挂起
EN

Stack Overflow用户
提问于 2021-11-11 16:07:14
回答 1查看 76关注 0票数 0

我使用HtmlAgilityPack将单词count作为页面长度的四分之一,使用asp.net Core查看从控制器返回的单词length /urls,并选择添加hr标记的任何元素(只是后面代码的占位符)。当我从另一个方法得到中间点时,代码工作得很好,并且附加得很完美,但出于某种原因,获取四分之一长度元素的代码只会使程序挂起,即使我有第一个季度节点的索引。

代码语言:javascript
复制
private static HtmlWeb web = new HtmlWeb();
private static HtmlDocument doc = web.Load('specific url address');
HtmlNode hr = doc.CreateElement("hr");

var quarterIndex = FirstQuarterTag(); //This returns an int of 5 to be passed in the line below
var xPathString = string.Format("//main[@id='main2']//div[@class='text-block']/*[{0}]", quarterIndex); //This returns the Xpath string "//main[@id='main2']//div[@class='text-block']/*[5]"

下面是导致程序挂起的行:

代码语言:javascript
复制
doc.DocumentNode.SelectSingleNode(xPathString).PrependChild(hr);

在选择不存在的节点(返回未定义的节点等)时,我遇到了错误。但这不会抛出错误,程序只是无限期地挂起。我假设它只是在给定的quarter字符串之前插入hr元素(当我找到中间点与第一季度标记时,这是有效的)。我只是在旋转车轮在这一点,所以任何帮助都是非常感谢。如果需要更多的信息,请告诉我。

编辑:下面是带有文本块类的div元素的标记。

代码语言:javascript
复制
        <div class="text-block">
            <h2 class="h3"></h2>
            <p>&nbsp;</p>
            <p>Big increases in sales can actually stunt business growth when a B2B company isn't prepared to meet the challenges in their online ecommerce operation such as making manual re-entries into back-office software, matching store data and inventory data and troubleshooting slowdowns and errors that create customer dissatisfaction. Manual entry and processes are just too antiquated, and even ERP and CRM software can't do the job properly unless the online store and back-office software communicate seamlessly and bidirectionally.</p>
            <p>The 
                <a href="/ecommerce-integrations/erp/oracle-integration">benefits of an ecommerce &amp; Oracle ERP integration</a> include the automation of most business processes. Data is validated outside the firewall before being accepted into the system, but this is accomplished in microseconds. Security protection is stronger while speeding the real-time dissemination of critical information and intelligence.</p>
            <p>
                <strong>Internal Management Benefits of integration with Oracle E-Business Suite</strong>
            </p>
            <p>Oracle E-Business Suite, or EBS, is a group of software applications that work with Oracle's acclaimed database software. The benefits of 
                <a href="/ecommerce-integrations/erp/oracle-integration">integration with Oracle E-Business Suite</a> include an 
                <a href="/ecommerce-integrations/erp/oracle-integration">automated point-to-point integration of Oracle CRM and ERP Platforms</a>. The E-Business Suite includes a range of application modules for different business needs including various aspects of CRM and ERP for wholesalers, retail sellers, distributors and manufacturers. Customer can get what they need as Software-as-a-Service, or SaaS, applications. [1]</p>
            <p>The benefits of integrating Oracle software applications for internal management include the following:</p>
            <p>
                <strong>Catalog Management</strong>
            </p>
            <ul>
                <li>The most critical 
                    <a href="/ecommerce-integrations/erp/oracle-integration">benefit of an Oracle ecommerce integration</a> is catalog management. B2B companies often deal with thousands of SKUs, and updating catalogs and prices becomes a nightmare without integration, which updates the information everywhere that the prices and content appear such as marketplace platforms, marketing communications, back-office accounting applications, social media pages and customer-specific pricing and pricing tiers.</li>
            </ul>
            <p>
                <strong>Supply Chain Management</strong>
            </p>
            <ul>
                <li>Oracle SCM Cloud offers advanced machine learning capabilities for better supply chain management. Companies can plan supply chain operations based on their evolving business needs, BI forecasts and demand-driven market trends. AI applications can gather information from thousands of sources to predict supply chain logjams, price increases and changes in supply and demand.</li>
            </ul>
            <p>
                <strong>Inventory Management</strong>
            </p>
            <ul>
                <li>Companies with fully integrated systems get a transparent view of all operations and warehouses in real-time to manage their inventories more strategically. Just-in-time inventory replenishment can save companies money, reduce dead inventory and ensure that stock levels match product demand.</li>
            </ul>
            <p>
                <strong>Customer Service</strong>
            </p>
            <ul>
                <li>Companies can offer their customers extended ways to communicate and request customer service in an integrated system. These methods include operating integrated customer service sites on social media, sending customers to external call centers, monitoring online chatter and reviews to address complaints and issues, providing FAQs and self-service features and offering live chat and chatbots to answer questions instantly.</li>
            </ul>
            <p>
                <strong>The User Experience</strong>
            </p>
            <p>The user experience, or UX, is critical in today's marketing and sales success. 
                <a href="/ecommerce-integrations/erp/oracle-integration">Oracle ecommerce integratio</a>n provides the following self-service capabilities that deliver outstanding UXs to each site visitor:</p>
            <ul>
                <li>Ability to access past invoices and buying history 24/7/365</li>
                <li>Onsite shipping integrations so that customers can choose from faster or cheaper shipping for each order</li>
                <li>Self-service options to request price quotes, product personalization and even custom products</li>
                <li>Automated tax and duty calculations for global sales</li>
                <li>Real-time currency conversions</li>
                <li>Access to product research resources</li>
                <li>Transparent information about the supply chain</li>
                <li>Drop shipping and split shipping available through self-service</li>
                <li>Automated fulfillment, product returns and delivery monitoring</li>
                <li>Extended payment options for customers</li>
            </ul>
            <p>An example of the benefits of extended payment options is that customers tend to buy where it's easy for them to pay. about 9 percent of retailers now offer Amazon Pay and 58 percent offer PayPal. PayPal transactions enjoy a 70 percent higher conversion rate than other payment methods. [2] Digital wallets, banks transfers, third-party payment services, internal credit accounts, POs and traditional credit and debit cards are used by B2B buyers, so accepting these payments is essential for increasing conversion rates. Clarity ecommerce can offer all these and more, helping to improve conversions by making purchasing easier for online shoppers.</p>
            <p>
                <strong>Understanding integration</strong>
            </p>
            <p>Although Oracle is a powerful system for managing online stores, most companies can't get the full benefits of integration out of the box unless they're building their platforms from scratch. There are always existing legacy systems, customer apps and other SaaS systems that won't connect without a custom integration. Some hardware and systems won't work because they're older models, but replacing major infrastructure could be extremely cost-prohibitive.</p>
            <p>Many companies don't choose Oracle Commerce as their sales platform for various reasons such as wanting to keep their existing software or needing access to the specialized features that other ecommerce platforms offer. Oracle software can be integrated with other ecommerce platforms--such as Clarity ecommerce--through a custom integration.</p>
            <p>
                <strong>Your Custom integration</strong>
            </p>
            <p>It's important to assess just how much technology you need before making any technology expansion. What existing systems do you want to preserve, and what level or technology can you afford? Working with an experienced B2B developer can solve many problems and manage your custom integration efficiently and less expensively. Clarity has 350 combined years of experience collaborating with major B2B platforms and companies that want to expand their businesses, and it has performed more than 3,000 integrations. The company works well with your IT staff, provides training, listens to your needs and specializes in B2B ecommerce and CRM-ERP integration development.</p>
            <p>
                <em>References:</em>
            </p>
            <p>[1] Searchoracle.techtarget.com: Oracle E-Business Suite</p>
            <p>
                <u>
                    <a href="https://searchoracle.techtarget.com/definition/Oracle-E-Business-Suite">https://searchoracle.techtarget.com/definition/Oracle-E-Business-Suite</a>
                </u>
            </p>
            <p>[2] 3dcart.com: Commerce statistics</p>
            <p>
                <u>
                    <a href="https://www.3dcart.com/ecommerce-market-statistics.html">https://www.3dcart.com/ecommerce-market-statistics.html</a>
                </u>
            </p>
            <article class="icon-box col-12 text-center py-7">
                <div class="icon-holder border border-dark flex-grow-1 rounded p-4 p-xl-6">
                    <header class="title-area">
                        <i class="icon d-flex align-items-center justify-content-center border border-dark bg-lightest">
                            <img src="/images/ico-guide.svg" alt="icon description" width="42" height="40">
                        </i>
                        <h3>Find out more</h3>
                        <p>Click here to review options to gather more info. From resource guides to complimentary expert review... we're here to help!</p>
                    </header>
                    <div class="btn-block">
                        <a href="#quote" class="btn btn-default">Get More Info</a>
                    </div>
                </div>
            </article>
        </div>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-11-12 13:02:18

我不明白你为什么有问题,这是我所做的测试:

代码语言:javascript
复制
        var doc = new HtmlDocument();
        doc.Load(@"you url", Encoding.UTF8);
        var node = doc.DocumentNode.SelectSingleNode("//main[@id='main2']//div[@class='text-block']/*[5]");
        HtmlNode hr = doc.CreateElement("hr");
        node.PrependChild(hr);

在破坏代码后的结果:

代码语言:javascript
复制
<main id="main2">
        <div class="text-block">
            <h2 class="h3"></h2>
            <p>&nbsp;</p>
            <p>Big increases in sales can actually stunt business growth when a B2B company isn't prepared to meet the challenges in their online ecommerce operation such as making manual re-entries into back-office software, matching store data and inventory data and troubleshooting slowdowns and errors that create customer dissatisfaction. Manual entry and processes are just too antiquated, and even ERP and CRM software can't do the job properly unless the online store and back-office software communicate seamlessly and bidirectionally.</p>
            <p>The 
                <a href="/ecommerce-integrations/erp/oracle-integration">benefits of an ecommerce &amp; Oracle ERP integration</a> include the automation of most business processes. Data is validated outside the firewall before being accepted into the system, but this is accomplished in microseconds. Security protection is stronger while speeding the real-time dissemination of critical information and intelligence.</p>
    ---->   <p><hr>
                <strong>Internal Management Benefits of integration with Oracle E-Business Suite</strong>
            </p>
            <p>Oracle E-Business Suite, or EBS, is a group of software applications that work with Oracle's acclaimed database software. The benefits of 
                <a href="/ecommerce-integrations/erp/oracle-integration">integration with Oracle E-Business Suite</a> include an 
                <a href="/ecommerce-integrations/erp/oracle-integration">automated point-to-point integration of Oracle CRM and ERP Platforms</a>. The E-Business Suite includes a range of application modules for different business needs including various aspects of CRM and ERP for wholesalers, retail sellers, distributors and manufacturers. Customer can get what they need as Software-as-a-Service, or SaaS, applications. [1]</p>
            <p>The benefits of integrating Oracle software applications for internal management include the following:</p>
            <p>
                <strong>Catalog Management</strong>
            </p>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69931445

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档