I'm trying to make a page using data from the discogs.com (XML)-API. i've been parsing it with simpleXML and it's working pretty well but there is some things i'm not sure how to do.
Here is part of the XML:
<releases>
<release id="1468764" status="Accepted" type="Main">
<title>Versions</title>
<format>12", EP</format>
<label>Not On Label</label>
<year>1999</year>
</release>
<release id="72246" status="Accepted" type="Main">
<title>The M.O.F Blend</title>
<format>LP</format>
<label>Blenda Records</label>
<year>2002</year>
</release>
<release id="890064" status="Accepted" type="Main">
<title>The M.O.F Blend</title>
<format>CD</format>
<label>Blenda Records</label>
<year>2002</year>
</release>
<release id="1563561" status="Accepted" type="TrackAppearance">
<title>Ännu En Gång Vol. 3</title>
<trackinfo>Backtrack</trackinfo>
<format>Cass, Comp, Mix</format>
<label>Hemmalaget</label>
<year>2001</year>
</release>
</releases>
What i want to achieve is something similair to how discogs presents the releases: http://www.discogs.com/artist/Mics+Of+Fury where diferent versions of the same release are sorted together. (see. The M.O.F Blend in my link) This is done on discogs with having a master release that features the other releases. unfortunately this information isn't present in the API data, so i want to do the same thing by grouping the <release>-nodes with the same <title>-tags, or add a flag to the <releases> that don't have a unique <title>? any good ideas on the best way of doing this?
i also like to know if it's possible to count the <release>-nodes (child of releases) that have the same type-attribute? like in this example count the releases with the type "Main"?
maybe it's better to do this things with XMLReader or XPath?
Hi
I've got a Flex 3 project. I'm having a problem with XML in Internet Explorer only. Pls see the problem lines below:
_clickURL = [email protected]();
_mediaSource = [email protected]();
These variables are coming up "" in IE. But, they grab the data in Safari and Firefox.
Any suggestions as to what the problem might be? Possible solution?
Thank you.
-Laxmidi
I have this xml model.
link text
So I have to add some node (see the text commented) to this file.
How I can do it?
I have writed this partial code but it doesn't work:
xmldoc=minidom.parse(directory)
child = xmldoc.createElement("map")
for node in xmldoc.getElementsByTagName("Environment"):
node.appendChild(child)
Thanks in advance.
If I do
XPathDocument doc = new XPathDocument("filename.xml");
Does that load the entire document into memory? I'm writing a mobile phone app and the document might store lots of data that doesn't ever need to all be loaded at the same time. Mobile phones don't usually have too much ram!
Hi,
I'm trying to add a "remember me" feature to my web app to let a user stay logged in between browser restarts. I think I got the bulk of it. I'm using google app engine for the backend which lets me use java servlets. Here is some pseudo-code to demo:
public class MyServlet {
public void handleRequest() {
if (getThreadLocalRequest().getSession().getAttribute("user") != null) {
// User already has session running for them.
}
else {
// No session, but check if they chose 'remember me' during
// their initial login, if so we can have them 'auto log in'
// now.
Cookie[] cookies = getThreadLocalRequest().getCookies();
if (cookies.find("rememberMePlz").exists()) {
// The value of this cookie is the cookie id, which is a
// unique string that is in no way based upon the user's
// name/email/id, and is hard to randomly generate.
String cookieid = cookies.find("rememberMePlz").value();
// Get the user object associated with this cookie id from
// the data store, would probably be a two-step process like:
//
// select * from cookies where cookieid = 'cookieid';
// select * from users where userid = 'userid fetched from above select';
User user = DataStore.getUserByCookieId(cookieid);
if (user != null) {
// Start session for them.
getThreadLocalRequest().getSession()
.setAttribute("user", user);
}
else {
// Either couldn't find a matching cookie with the
// supplied id, or maybe we expired the cookie on
// our side or blocked it.
}
}
}
}
}
// On first login, if user wanted us to remember them, we'd generate
// an instance of this object for them in the data store. We send the
// cookieid value down to the client and they persist it on their side
// in the "rememberMePlz" cookie.
public class CookieLong {
private String mCookieId;
private String mUserId;
private long mExpirationDate;
}
Alright, this all makes sense. The only frightening thing is what happens if someone finds out the value of the cookie? A malicious individual could set that cookie in their browser and access my site, and essentially be logged in as the user associated with it!
On the same note, I guess this is why the cookie ids must be difficult to randomly generate, because a malicious user doesn't have to steal someone's cookie - they could just randomly assign cookie values and start logging in as whichever user happens to be associated with that cookie, if any, right?
Scary stuff, I feel like I should at least include the username in the client cookie such that when it presents itself to the server, I won't auto-login unless the username+cookieid match in the DataStore.
Any comments would be great, I'm new to this and trying to figure out a best practice. I'm not writing a site which contains any sensitive personal information, but I'd like to minimize any potential for abuse all the same,
Thanks
Hello,
I want to be able to read any random RSS/ATOM XML file. That would mean I would not not know the tags, start the loop and the fields. How do I go about doing it in PHP.
Thanks
Jean
there are code snippets that strip the invalid characters inside a string before we save it as an XML ... but I have one more problem: Let's say my user wants to have a column name like "[MyColumnOne] ...so now I do not want to strip these "[","] well because these are the ones that user has defined and wants to see them so if I use some codes that are stripping the invalid characters they are also removing "[" and "[" but in this case I still need them to be saved... what can I do?
Hi, i am using this coding for my xml information to append in to html. As well it works fine. but in the ie7,ie8 as well chrome browser it's not propelry. This code work9ing well with firefox,opera, safari..
i unable to find, what is the mistake i made this.. any one help me please?
$(function(){
var thisPage;
var parentPage;
$('ul.left-navi li a').each(function(){
$('ul.left-navi li a').removeClass('current');
var pathname = (window.location.pathname.match(/[^\/]+$/)[0]);
var currentPage = $(this).attr('href');
var pathArr = new Array();
pathArr = pathname.split(".");
var file = pathArr[pathArr.length - 2];
thisPage = file;
if(currentPage==pathname){
$(this).addClass("active");
}
})
$.get('career-utility.xml',function(myData){
var receivedData = myData;
var myXml = $(myData).find(thisPage);
parentPage = thisPage;
var overviewTitle = myXml.find('overview').attr('title');
var description = myXml.find('discription').text();
var mainsublinkTitle = myXml.find('mainsublink').attr('title');
var thisTitle = myXml.find("intro").attr('title');
var thisIntro = myXml.find("introinfo").text();
$('<h3>'+overviewTitle+'</h3>').appendTo('.overViewInfo');
$('<p>'+description+'</p>').appendTo('.overViewInfo');
var sublinks = myXml.find('mainsublink').children('sublink');
$('#intro h3').append(thisTitle);
$('#intro').append(thisIntro);
sublinks.each(function(numsub){
var newSubLink = $(this);
var sublinkPage = $(this).attr('pageto');
var linkInfo = $(this).text();
$('ul.career-link').append('<li><a href="'+sublinkPage+'">'+linkInfo+'</a></li>');
})
// alert('thisTitle : '+thisTitle+'thisIntro :'+thisIntro);
$(myXml).find('listgroup').each(function(index){
var count = index;
var listGroup = $(this);
var listGroupTitle = $(this).attr('title');
var shortNote = $(this).attr('shortnote');
var subLink = $(this).find('sublist');
var firstList = $(this).find('list');
$('.grouplist').append('<div class="list-group"><h3>'+listGroupTitle+'</h3><ul class="level-one level' + count + '"></ul></div>');
firstList.each(function(listnum) {
$(this).wrapInner('<li>')
.find('sublistgroup').wrapInner('<ul>').children().unwrap()
.find('sublist').wrapInner('<li>').children().unwrap();
// Append content of 'list' node
$('ul.level'+count).append($(this).children());
});
});
});
})
I am attempting to add a WCF web service to my project and each time I add a new web service it adds a new Service Behavior, new Service configuration, and changes the formatting of my web.config.
Is it possible to add a new WCF Web service (.svc extension) to my project without it changing my web.config file? I am willing to add the information I need manually.
How can i update bulk data in sql server 2005 by sending the data in XML form ?
i am able to insert bulk data into the table, but i am not getting idea to update the data.
I want to convert a tab delimited text file to a XML file. I was able to do it with a single character delimiter. But how do i extend it to tabs? I am coding in C# and using Visual Studio 2010.
I want to add a unique attribute say "ind" to every tag in the xml. How do i do it using xsl. It need'nt be a sequence number. As long it is unique for every tag it is sufficient.
Input:Some textSome other textSome other text
Expected output: Some textSome other textSome other text
Hi,
I have a xml document which has only one element in the document, which is
<error>error string<error>
But when i try to parse it, it says this document has no element at all. In other words when i try to access the rootElement it says "null"
CXMLDocument *rssParser = [[[CXMLDocument alloc] initWithContentsOfURL:url options:0 error:nil] autorelease];
NSLog(@"Root: %@",[[rssParser rootElement] name]);
Please tell me what is wroing with this.
Thanks
Hi
<%
'Stage 1
datas=Server.URLencode("<PaginationData currentPage=""1"" totalPages=""9""/>")
response.write "Encode = " datas &"</br></br>"
'Stage 2
response.write "Decode = " 'How i again decode my encode data?
%>
In the "Stage 1" , i encode my xml data
In the "Stage 2", How i decode the "Stage 1" Encode data?
hoping your support
Having a code like this:
from lxml import etree
root = etree.Element("root")
root.set("interesting", "somewhat")
child1 = etree.SubElement(root, "test")
How do i write root Element object to an xml file using write() method of ElementTree class?
Hi,
I have a flash file that loads an xml file at runtime. When the .swf file is run locally or on an Apache server it works fine but when hosted on an IIS6 based server the file won't load.
can anyone help with this?
Thanks
Hi all,
How do I programatically upload an XSLT file to an SSRS server database?
I would like exactly the same functionality as the 'Upload File', preferably using the 'rs' command.
I have tried rs.CreateResource, but it doesn't seem to work for XML/XSLT files (though it works for Excel and image files)
I understand that manipulating the SSRS db is not supported.
Thanks
I am trying to build a python script that will take in an XML document and remove all of the comment blocks from it.
I tried something along the lines of:
tree = ElementTree()
tree.parse(file)
commentElements = tree.findall('//comment()')
for element in commentElements:
element.parentNode.remove(element)
Doing this yields a weird error from python: "KeyError: '()'
I know there are ways to easily edit the file using other methods ( like sed ), but I have to do it in a python script.
I have a manually created array that already works example below:
var PartsData = { 179: { ref:"",
partNum: "201-2007-C00-00",
descript: "System Monitor Card (Tracewell Only)",
cage: "39764",
qty: "1",
SMR: "XBOZZ",
UOC: "A" }};
Now this array above is is just one value in the array and it works fine. Here is the XML that I am trying to use to dynamically change the values.
<?xml version="1.0" encoding="utf-8"?>
<partsTables>
<partsList>
<part sheetNum="ta1">
<breakDownIndexNo>-1 </breakDownIndexNo>
<referenceDesg/>
<indent>20534220P01 </indent>
<description/>
<cage>TAC RI, GRADE-A SHOCK (TEC RACK), ALT P/N 72304-1</cage>
<qtyPerAssy>23991 </qtyPerAssy>
<smr>1 </smr>
<uoc>ADODD </uoc>
<blank/>
</part>
</partsList>
</partsTables>
I have this parsing just fine in Acrobat. Now I want to make the array work for me in using these values. if I have the following below it will work.
Where part.item(i).indent.value equals the value of the indent node, etc.
newArr = { 179: {
ref: part.item(i).referenceDesg.value,
partNum: part.item(i).indent.value,
descript: part.item(i).cage.value,
cage: part.item(i).qtyPerAssy.value,
qty: part.item(i).smr.value,
SMR: part.item(i).uoc.value,
UOC: part.item(i).blank.value}};
As soon as I try to make the 179 value, which is in the breakDownIndexNo node, dynamic by using the direct part.item(i).breakDownIndexNo.value it will not compile. Acrobat is using javascript so I'm not sure why I can not get this to parse.
I have tried to create a variable out of the breakDownIndexNo node and typed it to both a String and an Integer. this will let it create the array but it will not let me output from the array. newArr[indexNum].partNum gives me "no properties" where newArr[179].partNum if I were to manually set the index number to 179 will print out the value of part.item(i).indent.value.
If any of you have an idea or an answer please let me know.
I am building an application using Action script 3 I am retrieving some XML from the web however the node names are mms:Image mms:Results etc my action script compiler is throwing an error becuase it is not expecting to see the semi colon in the node name. How to I access the nodes?
thanks