The variable #photo contains this XML:
<photo id="2733">
<urls>
<url type="photopage">http://www.flickr.com/photos/bees/2733/</url>
</urls>
</photo>
I need to get its url and I tried to do that by #photo.urls.url but I couldn't. How do access http address http://www.flickr.com/photos/bees/2733/?
You could use the nokogiri gem. Is is made to manipulate xml documents.
Related
I can't validate script tag with attribute nomodule.
I am using odoo framework which is a python backend. It is using lxml to validate xml views or pages. I am building a view with a script tag like:
<script src="src.js" nomodule></script>
It returns an error
lxml.etree.XMLSyntaxError: Specification mandate value for attribute nomodule
However this should be valid according to https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script
Is there a way so that I can make the parser ignore this new attribute or I can bypass such as special data or character.
That's possibly because XML != HTML. And as you can see in the error, it's an XML error.
Is an xml attribute without a value, valid? --> your attribute isn't valid.
You need to specify the attribute value always in xml. Odoo uses xml to produce html, so you need to comply with xml rules. You can do it in this case by specifying an empty value for xml attribute like this:
<script src="src.js" nomodule=””></script>
I am trying to create a dynamic XML sitemap for my ASP.NET MVC web application. The pages are structured and predictable based on the data retrieved from the database by an entity framework 6 model. I would like to simply use XML literals to retrieve each item from the database, sort of like what happens here.
My statement looks like the following:
Dim xmlSitemap = <?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://example.com</loc>
</url>
<url>
<loc>https://example.com/Home/Contact</loc>
</url>
<%= From blog in db.Blogs Select <url>
<loc>https://example.com/BlogPosts/<%= blog.PostId %></loc>
</url> %>
</urlset>
Running this code results in System.NotSupportedException: 'Only parameterless constructors and initializers are supported in LINQ to Entities.'
Modifying the model to include a Public Sub New() with no arguments does nothing to remedy this error. Based on my research after trying that, I'm guessing that this has to do with the fact that I am concatenating strings within the Linq query, but I don't know another way. Is there a way to create the sitemap this way, or am I asking too much?
I'm guessing that at a .NET level, the compiled expression that's generated by that tag is too complex to handle within Entity Framework (i.e. in a SQL statement). Try adding .ToList() or .AsEnumerable() after db.Blogs to force the rest of your LINQ statement into a LINQ-to-Objects context.
Note: You'll want to make sure you understand what this is doing, and avoid doing .ToList() before a Where clause, for example, so avoid serious performance penalties.
I have this soap response and i need to get the value of the tag platformMessage i writed a xpath query but it doesnt work, checking the log file in jmeter in tells me this "Prefix must resolve to a namespace: ns2", heres the xpath query
/S:Envelope[#xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"]/S:Body/ns2:activateProductResponse[#xmlns:ns2="http://ws.business.api.fulfillmentengine.com/"]/return/platformMessage
heres the xml
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:activateProductResponse xmlns:ns2="http://ws.business.api.fulfillmentengine.millicom.com/">
<return>
<platformCode>1</platformCode>
<platformMessage>Fail operation.El set-top box ya existe. Code Response:|22098: 22098: 1</platformMessage>
<responseCode>13</responseCode>
<responseMessage>Error executing action in platforn</responseMessage>
<UUID>3cb49b29-513e-11e6-b5db-005056807f0c</UUID>
<platformName>INTRAWAY</platformName>
</return>
</ns2:activateProductResponse>
</S:Body>
</S:Envelope>
Using #xmlns:ns2 in the xpath is not valid because despite appearances a namespace is not the same as an attribute.
If you enable "use namespaces", then the following xpath should work:
/S:Envelope/S:Body/ns2:activateProductResponse/return/platformMessage
Or if you want a dirty (and slow) workaround, you can reference the node names like so:
/*[local-name()='Envelope']/*[local-name()='Body']/*/[local-name()='activateProductResponse]/return/platformMessage
you should read:
https://jmeter.apache.org/usermanual/component_reference.html#XPath_Extractor
https://jmeter.apache.org/usermanual/component_reference.html#XPath_Assertion
pay particular attention to:
As a work-round for namespace limitations of the Xalan XPath parser implementation on which JMeter is based, you can provide a Properties file which contains mappings for the namespace prefixes:
prefix1=Full Namespace 1
prefix2=Full Namespace 2
…
You reference this file in jmeter.properties file using the property:
xpath.namespace.config
Look in jmeter.properties for this property and everything is explained clearly
I'm able to create new Story via POST to /VersionOne/rest-1.v1/Data/Story with corresponding XML payload. Setting all attributes (including relational) works like a charm. However I'm unable to figure out how to add a Link asset to the Story asset.
When I try POSTing to /VersionOne/rest-1.v1/Data/Link with following XML payload:
<Asset href='/VersionOne/rest-1.v1/New/Link'>
<Attribute name='AssetType' act='set'>Link</Attribute>
<Relation name='Asset' act='set'>
<Asset href='/VersionOne/rest-1.v1/Data/Story/123' idref='Story:123'/>
</Relation>
<Attribute name='OnMenu' act='set'>true</Attribute>
<Attribute name='URL' act='set'>http://my.example.com</Attribute>
<Attribute name='Name' act='set'>My Link Title</Attribute>
</Asset>
The server however returns:
<Error href="/VersionOne/rest-1.v1/Data/Link">
<Message>Violation'Readonly'Link.AssetType</Message>
<Exception class="VersionOne.DataException">
<Message>Violation'Readonly'Link.AssetType</Message>
</Exception>
</Error>
Seems like adding links is prohibited but actually I can add Links via the standard web interface without issues.
My original idea was to create Link asset first and then update the Story with respective relational attribute pointing to that Link asset.
Any ideas anyone?
Thanks!
(I'm using JavaScript/jQuery)
My bad. The <Attribute name='AssetType' act='set'>Link</Attribute> attribute in the POST payload is obviously wrong - it is trying to set the asset's type (link) which does not make sense since I'm stating the type in URL already. It works perfectly without the attribute (as expected).
I am being returned some XML from a web service. Basically, the xml looks like this:
<response>
<data>
More XML here but the it's escaped by XML entities
</data>
</response>
so, as you can see, I have xml that is valid, but the stuff inside data tag is escaped with XML entities. what's the best (most efficient) way for me to feed this into the parser?
What I am doing right now is, when I get the data from web service, I convert it into NSString....then replace the "XML escaped entities" with real ones.....then convert it back into NSData...then feed it into the parser. This doesn't seem like a very good solution so I was wondering if there's a better way to do it?
Thanks.
Alright, here's the xml that I am getting:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Header><ActivityId CorrelationId="d39007b5-ee69-41c7-a61d-831b456f9ea3" xmlns="http://schemas.microsoft.com/2004/09/ServiceModel/Diagnostics">aa88d1cd-253c-48d1-abeb-62a880bea806</ActivityId></s:Header><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><LoginResponse xmlns="http://MSS"><LoginResult><LoginInformation>
<User>
<UserID>612</UserID>
<UserName>Demo User</UserName>
<Email>mssdev#mss-mail.com</Email>
<CompanyID>17034</CompanyID>
<CompanyName>PlanET Demonstration Agency</CompanyName>
</User>
</LoginInformation></LoginResult></LoginResponse></s:Body></s:Envelope>
As you can see, everything in is escaped.
That's kind of horrifying. Why don't you just take the contents of that tag (e.g. the data with the entities) and just pass that through another NSXMLParser? The first parser will have decoded the entities, and the second parser will be presented with the decoded version of the contents of that tag.