xml-parsing 相关问题

XML解析器遍历包含XML树的文本文档,并允许使用层次结构中的信息。将此标记用于实现XML解析器的问题,或者通过使用给定语言的现有解析器生成的问题。

sql 作业中的 Xml 解析问题

我在 SQL Server 作业中执行查询时遇到错误。但如果我直接执行它,它就可以正常工作。 以用户身份执行:NT AUTHORITY\SYSTEM。 XML解析:第10行,第33个字符

回答 3 投票 0

如果在指定日期范围内,如何申请每个组并为每个列出的代码返回 1 行?

我正在尝试在代码中创建几个嵌套循环,以按 Time_Data/Time_Off/Code 进行分组。我想在输出中的 1 行上显示连续几天内的所有休假代码。任何补充...

回答 1 投票 0

我如何找出 xpath 中的属性是否包含特定列表中的任何值

我如何找出 xpath 中的属性是否包含特定列表中的任何值, 例如,在下面的情况下,我想从列表 {&quo...

回答 3 投票 0

使用 pandas read_xml 解析具有公共列名称的嵌套 XML

我有一个带有公共列名称(在本例中为名称)的嵌套 xml 文件。我需要解析此 XML 以具有不同的列。 坦美 ...

回答 1 投票 0

在 Google 表格中使用 IMPORTXML 从 Google 支持页面提取元素时遇到问题

我正在尝试使用 Google 表格中的 IMPORTXML 函数从特定的 Google 支持页面提取元素。该公式适用于其他 URL,但当我在 Google 支持上使用它时...

回答 1 投票 0

如何读写XML文件?

我必须读取和写入 XML 文件。使用 Java 读写 XML 文件的最简单方法是什么?

回答 7 投票 0

解析js对象中的数组对象到xml不起作用

嘿,我正在尝试将 javascript 对象解析为 node.js 应用程序中的 xml 字符串。我像这样使用 npm 包 json2xml json2xml(jsonObject, { 标头: true }); 我的问题是当有一个数组时

回答 5 投票 0

PHP-Laravel Amazon feed XML 解析第 1 行第 1 列发生致命错误

1.02 <AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd"> <Header> <DocumentVersion>1.02</DocumentVersion> <MerchantIdentifier>MYMERCHANT123</MerchantIdentifier> </Header> <MessageType>ProcessingReport</MessageType> <Message> <MessageID>1</MessageID> <ProcessingReport> <DocumentTransactionID>172210019669</DocumentTransactionID> <StatusCode>Complete</StatusCode> <ProcessingSummary> <MessagesProcessed>0</MessagesProcessed> <MessagesSuccessful>0</MessagesSuccessful> <MessagesWithError>1</MessagesWithError> <MessagesWithWarning>0</MessagesWithWarning> </ProcessingSummary> <Result> <MessageID>0</MessageID> <ResultCode>Error</ResultCode> <ResultMessageCode>5001</ResultMessageCode> <ResultDescription>XML Parsing Fatal Error at Line 1, Column 1: Content is not allowed in prolog. Content is not allowed in prolog.</ResultDescription> </Result> </ProcessingReport> </Message> </AmazonEnvelope> 这是我的错误,这是我的代码: $requestXml = '<?xml version="1.0" encoding="utf-8"?> <AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd"> <Header> <DocumentVersion>1.01</DocumentVersion> <MerchantIdentifier>MYMERCHANT123</MerchantIdentifier> </Header> <MessageType>Product</MessageType> <PurgeAndReplace>false</PurgeAndReplace> <Message> <MessageID>1</MessageID> <OperationType>Update</OperationType> <Product> <SKU>56789</SKU> <StandardProductID> <Type>ASIN</Type> <Value>B0EXAMPLEG</Value> </StandardProductID> <ProductTaxCode>A_GEN_NOTAX</ProductTaxCode> <DescriptionData> <Title>Example Product Title</Title> <Brand>Example Product Brand</Brand> <Description>This is an example product description.</Description> <BulletPoint>Example Bullet Point 1</BulletPoint> <BulletPoint>Example Bullet Point 2</BulletPoint> <MSRP currency="USD">25.19</MSRP> <Manufacturer>Example Product Manufacturer</Manufacturer> <ItemType>example-item-type</ItemType> </DescriptionData> <ProductData> <Health> <ProductType> <HealthMisc> <Ingredients>Example Ingredients</Ingredients> <Directions>Example Directions</Directions> </HealthMisc> </ProductType> </Health> </ProductData> </Product> </Message> </AmazonEnvelope>'; // $requestXml = trim($requestXml); // doesn't help // $requestXml = preg_replace('/[[:^print:]]/', '', $requestXml); // $requestXml = preg_replace('/^(\xEF\xBB\xBF)/', '', $requestXml); $response = Http::withHeaders([ 'Content-Type' => 'text/xml; charset=utf-8' ])->put($url, [ 'body' => $requestXml ]); 我希望有人可以帮助我,因为我快疯了,因为几天后我无法解决这个问题,但这很重要。 我尝试了在互联网上找到的所有内容,阅读了 Stackoverflow 上的所有内容,但没有解决我的问题。 我还尝试从文件中调用它(我通过 Notepad++ 将其保存为 UTF-8) $prefixAmazon = Storage::disk('amazon')->getDriver()->getAdapter()->getPathPrefix(); $requestXml = file_get_contents($prefixAmazon . 'createFeed.xml'); 我找到了使用 Amazon SP-API 在 Laravel 中创建产品源的解决方案 (https://github.com/amazon-php/sp-api-sdk): composer require amazon-php/sp-api-sdk composer require nyholm/psr7 -W use AmazonPHP\SellingPartner\AccessToken; use AmazonPHP\SellingPartner\Model\Feeds\CreateFeedDocumentSpecification; use AmazonPHP\SellingPartner\Model\Feeds\CreateFeedSpecification; use AmazonPHP\SellingPartner\Regions; use AmazonPHP\SellingPartner\SellingPartnerSDK; use App\Models\Amazon\AmazonAuth; use Exception; use GuzzleHttp\Handler\CurlFactory; use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\App; use Carbon\Carbon; use Illuminate\Support\Facades\Storage; use GuzzleHttp\Client; use AmazonPHP\SellingPartner\Api\FeedsApi\FeedsSDK; use AmazonPHP\SellingPartner\Configuration; use AmazonPHP\SellingPartner\Exception\ApiException; use AmazonPHP\SellingPartner\Exception\InvalidArgumentException; use AmazonPHP\SellingPartner\HttpFactory; use AmazonPHP\SellingPartner\HttpSignatureHeaders; use AmazonPHP\SellingPartner\ObjectSerializer; use Psr\Http\Client\ClientExceptionInterface; use Psr\Http\Client\ClientInterface; use Psr\Http\Message\RequestInterface; use Psr\Log\LoggerInterface; use AmazonPHP\SellingPartner\OAuth; use Buzz\Client\Curl; use Nyholm\Psr7\Factory\Psr17Factory; use Psr\Log\NullLogger; public function getAccessToken($channelId) { $amazonAuth = AmazonAuth::where('channel_id', $channelId)->first(); //my local database channel $isExpired = Carbon::parse($amazonAuth->expires_at)->isPast(); $token = null; if ($isExpired) { $data = [ 'grant_type' => 'refresh_token', 'refresh_token' => $amazonAuth->refresh_token, 'client_id' => TenantService::getLwaClientId(), 'client_secret' => TenantService::getLwaSecret() ]; $response = Http::asForm()->post( 'https://api.amazon.com/auth/o2/token', $data ); if ($response->successful()) { $body = $response->json(); $amazonAuth->access_token = $body['access_token']; $amazonAuth->expires_at = now()->addSeconds($body['expires_in'])->toDateTimeString(); $amazonAuth->save(); $token = $body['access_token']; } else { Log::channel('amazon')->info('Amazon access token refresh failed for amazon auth id: ' . $amazonAuth->id); } } else { $token = $amazonAuth->access_token; } if ($token) { $accessToken = new AccessToken( $token, $amazonAuth->refresh_token, 'refresh_token', (int) $amazonAuth->expires_in, 'refresh_token' ); return $accessToken; } } public function createFeedTest() { $client = new Client(); $factory = new Psr17Factory(); // $httpFactory = new HttpFactory($factory, $factory); $region = 'eu'; $accessToken = $this->getAccessToken(150); $logger = new NullLogger(); $configuration = Configuration::forIAMUser( $getLwaClientId, $getLwaSecret, $getAwsAccessKey, $getAwsSecretKey, ); $sdk = SellingPartnerSDK::create($client, $factory, $factory, $configuration, $logger); $region = Regions::EUROPE; $specification = new CreateFeedDocumentSpecification; $feedDoc = $sdk->feeds()->createFeedDocument( $accessToken, $region, $specification->setContentType('text/xml; charset=utf-8') ); $feedDocID = $feedDoc['feed_document_id']; $urlFeedUpload = $feedDoc['url']; $fileContent = '<?xml version="1.0" encoding="utf-8" ?> <AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd"> <Header> <DocumentVersion>1.01</DocumentVersion> <MerchantIdentifier>MYMERCHANTTOKEN</MerchantIdentifier> </Header> <MessageType>Product</MessageType> <PurgeAndReplace>false</PurgeAndReplace> <Message> <MessageID>1</MessageID> <OperationType>Update</OperationType> <Product> <SKU>56789</SKU> <StandardProductID> <Type>ASIN</Type> <Value>B0EXAMPLEG</Value> </StandardProductID> <ProductTaxCode>A_GEN_NOTAX</ProductTaxCode> <DescriptionData> <Title>Example Product Title</Title> <Brand>Example Product Brand</Brand> <Description>This is an example product description.</Description> <BulletPoint>Example Bullet Point 1</BulletPoint> <BulletPoint>Example Bullet Point 2</BulletPoint> <MSRP currency="USD">25.19</MSRP> <Manufacturer>Example Product Manufacturer</Manufacturer> <ItemType>example-item-type</ItemType> <CountryOfOrigin>DE</CountryOfOrigin> <UnitCount>1</UnitCount> <PPUCountType>stück</PPUCountType> <IsExpirationDatedProduct>false</IsExpirationDatedProduct> </DescriptionData> <ProductData> <Health> <ProductType> <HealthMisc> <Ingredients>Example Ingredients</Ingredients> <Directions>Example Directions</Directions> </HealthMisc> </ProductType> </Health> </ProductData> <IsHeatSensitive>false</IsHeatSensitive> </Product> </Message> </AmazonEnvelope>'; dump($feedDoc); $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $urlFeedUpload); curl_setopt($curl, CURLOPT_UPLOAD, true); curl_setopt($curl, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS); curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: text/xml; charset=utf-8')); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_BINARYTRANSFER, 1); curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_PUT, 1); curl_setopt($curl, CURLOPT_INFILE, fopen('data://text/plain,' . $fileContent, 'r')); curl_setopt($curl, CURLOPT_INFILESIZE, strlen($fileContent)); #Only use below option on TEST environment if you have a self-signed certificate!!! On production this can cause security issues curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); $response = curl_exec($curl); dump($response); curl_close($curl); $specificationNewFeed = new CreateFeedSpecification([ 'feed_type' => 'POST_PRODUCT_DATA', 'marketplace_ids' => ['A1PA6795UKMFR9'], 'input_feed_document_id' => $feedDocID ]); $responseFeed = $sdk->feeds()->createFeed( $accessToken, $region, $specificationNewFeed ); dd($responseFeed); }

回答 1 投票 0

Foreach 字符串参数 PHP

我像这样解析XML 2 1号楼 图片.jpg

回答 1 投票 0

Laravel:第 1 行第 1 列出现 XML 解析致命错误:序言中不允许出现内容。序言中不允许出现内容

我正在尝试使用 Laravel 在亚马逊卖家帐户中发布产品。但我收到错误: XML 解析致命错误位于第 1 行第 1 列:序言中不允许出现内容。 p 中不允许有内容...

回答 1 投票 0

Xpath 里面的 Xpath

我正在尝试为以下场景创建一个xpath,你能帮忙吗? 如何找出@parent为/A/B/@id的C的值,即PQR,C可能不是紧邻的下一个节点。我想要...

回答 1 投票 0

Notepad++如何替换文本的随机位置

我想替换 XML 中的一些字符串,但我不知道如何“标记”?字符串。我从 Opera 丢失了密码,但我从 Mozilla 获得了旧副本,但它们位于不同的组并解析...

回答 1 投票 0

XML 反序列化错误 - CLR/System.InvalidOperationException

我尝试将 XML 文件反序列化为对象,但我不断收到相同的错误(如下所述)。我相信我已经正确映射了反对意见。我一直在使用本指南和视频作为

回答 1 投票 0

将“XML Spreadsheet 2003”解析为 Pandas 数据框

我有 6000 多个 XML 电子表格文件,我想将它们解析为 Pandas DataFrames。最好我想使用 pd.read_xml 方法来执行此操作并提供正确的参数(x-path?)。我...

回答 1 投票 0

Pandas read_xml 和 SEPA (CAMT 053) XML

最近我想尝试一下pandas中新实现的xml_read函数。我考虑使用 SEPA camt-format xml 测试该功能。我被函数参数困住了,因为我不熟悉......

回答 2 投票 0

如何从XML文档Java中获取键值对

我有一个 XML 文档,我想从中检索该 XML 文档的键和值。然而我在两者上都遇到困难,我意识到我应该使用 Map 的数据类型,但我不......

回答 2 投票 0

VBA 中的 XML 解析出现问题:从 NodeList 中提取多个节点值

下面的 XML 文档是包含订单项目的发票。 必须为每个订单项目提取各种主数据。 为了简单起见,我们只考虑 ...

回答 1 投票 0

当子节点变化时将 XML 节点提取到数据框中

我正在 R 中构建代码,以从 IRS990PF 文件中提取 XML 格式的拨款数据。我构建了以下代码,该代码可以很好地为仅包含美国受助者的文件构建数据框。然而,那...

回答 1 投票 0

在 Python 中从文件路径解析 MusicXML 文件时遇到问题

我正在开发一个Python项目,我需要解析MusicXML文件。到目前为止,我已经手动将这些文件中的内容复制到字符串变量中,并且代码运行良好。然而,...

回答 1 投票 0

如何在 xml 模式中使用序列和非序列子级

1。我有一个格式良好的 xml,如下所示 g0 测试 a ...

回答 1 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.